]> arthur.barton.de Git - netatalk.git/blobdiff - libevent/bufferevent.c
Add silent rules to libevent
[netatalk.git] / libevent / bufferevent.c
index 9855d18322c1d93db961d72b65effa4a621f040d..45a1437e70563e3868b19492e45e2fa61de2030d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2002-2007 Niels Provos <provos@citi.umich.edu>
- * Copyright (c) 2007-2010 Niels Provos, Nick Mathewson
+ * Copyright (c) 2007-2012 Niels Provos, Nick Mathewson
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -59,6 +59,9 @@
 #include "evbuffer-internal.h"
 #include "util-internal.h"
 
+static void _bufferevent_cancel_all(struct bufferevent *bev);
+
+
 void
 bufferevent_suspend_read(struct bufferevent *bufev, bufferevent_suspend_flags what)
 {
@@ -674,6 +677,7 @@ bufferevent_free(struct bufferevent *bufev)
 {
        BEV_LOCK(bufev);
        bufferevent_setcb(bufev, NULL, NULL, NULL, NULL);
+       _bufferevent_cancel_all(bufev);
        _bufferevent_decref_and_unlock(bufev);
 }
 
@@ -750,6 +754,17 @@ bufferevent_getfd(struct bufferevent *bev)
        return (res<0) ? -1 : d.fd;
 }
 
+static void
+_bufferevent_cancel_all(struct bufferevent *bev)
+{
+       union bufferevent_ctrl_data d;
+       memset(&d, 0, sizeof(d));
+       BEV_LOCK(bev);
+       if (bev->be_ops->ctrl)
+               bev->be_ops->ctrl(bev, BEV_CTRL_CANCEL_ALL, &d);
+       BEV_UNLOCK(bev);
+}
+
 short
 bufferevent_get_enabled(struct bufferevent *bufev)
 {