On Tue, Jun 10, 2014 at 10:02:24AM +0200, Daniel Willmann wrote:
From: Daniel Willmann <dwillmann(a)sysmocom.de>
If the FD is both readable and writable and the read callback closes the
connection (and frees the surrounding structure) we shouldn't call the
write callback (or check anything else in the read fd).
With this patch callback functions can return -EBADFD if they don't want
the FD to be handled any more.
---
src/write_queue.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/src/write_queue.c b/src/write_queue.c
index cef40f8..dcc0469 100644
--- a/src/write_queue.c
+++ b/src/write_queue.c
@@ -21,8 +21,15 @@
*
*/
+#include <errno.h>
#include <osmocom/core/write_queue.h>
+#define HANDLE_BAD_FD(rc, label) \
+ do { \
+ if (rc == -EBADFD) \
+ goto label; \
+ } while (0);
Do we really get anything good with this macro? This checking is only
required in three places in this patch.