From 02af3f4c732333a9586f733cdceea36417500072 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Sat, 9 May 2015 19:18:40 +0200 Subject: [PATCH] ensure direct exit after calling back any structures may be invalid after callback invocation. this has the side effect that the socket write callback now returns void, like all other callbacks do. --- src/drv_imap.c | 5 ++--- src/socket.c | 5 +++-- src/socket.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/drv_imap.c b/src/drv_imap.c index 6a1394d..31fdf28 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -335,7 +335,7 @@ cmd_submittable( imap_store_t *ctx, struct imap_cmd *cmd ) ctx->num_in_progress < ((imap_store_conf_t *)ctx->gen.conf)->server->max_in_progress; } -static int +static void flush_imap_cmds( imap_store_t *ctx ) { struct imap_cmd *cmd; @@ -345,7 +345,6 @@ flush_imap_cmds( imap_store_t *ctx ) ctx->pending_append = &ctx->pending; send_imap_cmd( ctx, cmd ); } - return 0; } static void @@ -1589,7 +1588,7 @@ imap_open_store( store_conf_t *conf, const char *label, socket_init( &ctx->conn, &srvc->sconf, (void (*)( void * ))imap_invoke_bad_callback, - imap_socket_read, (int (*)(void *))flush_imap_cmds, ctx ); + imap_socket_read, (void (*)(void *))flush_imap_cmds, ctx ); socket_connect( &ctx->conn, imap_open_store_connected ); } diff --git a/src/socket.c b/src/socket.c index 8a3b33b..5c1ce93 100644 --- a/src/socket.c +++ b/src/socket.c @@ -80,7 +80,7 @@ ssl_return( const char *func, conn_t *conn, int ret ) /* Callers take the short path out, so signal higher layers from here. */ conn->state = SCK_EOF; conn->read_callback( conn->callback_aux ); - return 0; + return -1; } sys_error( "Socket error: secure %s %s", func, conn->name ); } else { @@ -766,7 +766,8 @@ do_queued_write( conn_t *conn ) conf_wakeup( &conn->ssl_fake, 0 ); #endif conn->writing = 0; - return conn->write_callback( conn->callback_aux ); + conn->write_callback( conn->callback_aux ); + return -1; } static void diff --git a/src/socket.h b/src/socket.h index dac2576..84ae0a2 100644 --- a/src/socket.h +++ b/src/socket.h @@ -88,7 +88,7 @@ typedef struct { void (*bad_callback)( void *aux ); /* async fail while sending or listening */ void (*read_callback)( void *aux ); /* data available for reading */ - int (*write_callback)( void *aux ); /* all *queued* data was sent */ + void (*write_callback)( void *aux ); /* all *queued* data was sent */ union { void (*connect)( int ok, void *aux ); void (*starttls)( int ok, void *aux ); @@ -123,7 +123,7 @@ static INLINE void socket_init( conn_t *conn, const server_conf_t *conf, void (*bad_callback)( void *aux ), void (*read_callback)( void *aux ), - int (*write_callback)( void *aux ), + void (*write_callback)( void *aux ), void *aux ) { conn->conf = conf;