rem: if (_p->flags & PFLAG_WATCHERINFO_CHANGED) { if (!presentity_changed) {  watcher_t *w = _p->watchers; while (w) { if (w && w->flags) LOG(L_ERR, "\t w=%p %.*s flags=%x\n", w, w->uri.len, w->uri.s, w->flags); if (w->flags & WFLAG_SUBSCRIPTION_CHANGED) { if (send_notify(_p, w) < 0) { LOG(L_ERR, "handle_subscription(): Error while sending notify\n");  } w->flags &= ~WFLAG_SUBSCRIPTION_CHANGED; } w = w->next; } }  notify_winfo_watchers(_p);
add: if (presentity_changed) {  notify_qsa_watchers(_p);
context: int timer_presentity(presentity_t* _p){	watcher_t* watcher, *t;	presence_tuple_t *tuple;	int changed;	int presentity_changed;	if (_p && _p->flags)	     LOG(L_ERR, "timer_presentity: _p=%p %.*s flags=%x watchers=%p\n", 		 _p, _p->uri.len, _p->uri.s, _p->flags, _p->watchers);	presentity_changed = _p->flags & (PFLAG_PRESENCE_CHANGED			|PFLAG_PRESENCE_LISTS_CHANGED			|PFLAG_XCAP_CHANGED			|PFLAG_LOCATION_CHANGED);			if (_p->flags & PFLAG_WATCHERINFO_CHANGED) {		if (!presentity_changed) { /* other will be notified below ! */			watcher_t *w = _p->watchers;			while (w) {				 if (w && w->flags)				  LOG(L_ERR, "\t w=%p %.*s flags=%x\n", w, w->uri.len, w->uri.s, w->flags);				 if (w->flags & WFLAG_SUBSCRIPTION_CHANGED) {					if (send_notify(_p, w) < 0) {						LOG(L_ERR, "handle_subscription(): Error while sending notify\n");						/* FIXME: watcher and presentity should be test for removal here						 * (and possibly in other error cases too						 */					}					w->flags &= ~WFLAG_SUBSCRIPTION_CHANGED;				}				w = w->next;			}		}		notify_winfo_watchers(_p);		     /* We remove it here because a notify needs to be send first */		// if (w->expires == 0) free_watcher(w);		// if (p->slot == 0) free_presentity(p);	}	if (presentity_changed) {		notify_watchers(_p);	}		_p->flags &= ~PFLAG_WATCHERINFO_CHANGED; /* clean this flag - it is after */	changed = 0;	tuple = _p->tuples;	while (tuple) {	  presence_tuple_t *next_tuple = tuple->next;	  if (tuple->expires < act_time) {	    LOG(L_ERR, "Expiring tuple %.*s\n", tuple->contact.len, tuple->contact.s);	    remove_presence_tuple(_p, tuple);		free_presence_tuple(tuple); /* FIXME: experimental */		changed = 1;	  }	  tuple = next_tuple;	}	if (changed == 1) {		db_update_presentity(_p);		_p->flags |= PFLAG_PRESENCE_CHANGED; /* FIXME: hack due to incorrect client's reaction on more tuples */	}	watcher = _p->watchers;	if (0) print_presentity(stdout, _p);	while(watcher) {	        if (watcher->expires <= act_time) {		  LOG(L_ERR, "Removing watcher %.*s\n", watcher->uri.len, watcher->uri.s);			watcher->expires = 0;			_p->flags |= PFLAG_WATCHERINFO_CHANGED;			send_notify(_p, watcher);			t = watcher;			watcher = watcher->next;			remove_watcher(_p, t);			free_watcher(t);			continue;		}				watcher = watcher->next;	}	watcher = _p->winfo_watchers;	while(watcher) {	        if (watcher->expires <= act_time) {		  LOG(L_ERR, "Removing watcher %.*s\n", watcher->uri.len, watcher->uri.s);			watcher->expires = 0;			_p->flags |= PFLAG_WATCHERINFO_CHANGED;			send_notify(_p, watcher);			t = watcher;			watcher = watcher->next;			remove_winfo_watcher(_p, t);			free_watcher(t);			continue;		}				watcher = watcher->next;	}	return 0;}