+ }
+ pthread_rwlock_unlock(&listener->rwlock);
+
+ /* recycle memory */
+ free(watch);
+}
+
+static void listener_unwatch(struct afb_evt_listener *listener, struct afb_evtid *evtid, struct afb_evt_watch *watch, int remove)
+{
+ struct afb_evt_watch **prv;
+
+ /* notify listener if needed */
+ unwatch(listener, evtid, remove);
+
+ /* unlink the watch for its event */
+ pthread_rwlock_wrlock(&evtid->rwlock);
+ prv = &evtid->watchs;
+ while(*prv) {
+ if (*prv == watch) {
+ *prv = watch->next_by_evtid;
+ break;
+ }
+ prv = &(*prv)->next_by_evtid;
+ }
+ pthread_rwlock_unlock(&evtid->rwlock);