]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Return async event produced
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Apr 2018 16:00:02 +0000 (17:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 13 Apr 2018 16:02:11 +0000 (17:02 +0100)
src/libserver/events.c
src/libserver/events.h

index baf108e38db90720c859e7bb619da447b5e93eca..c12b5e2f35a4b7aca768209e71c8eaac440720ee 100644 (file)
@@ -127,37 +127,40 @@ rspamd_session_create (rspamd_mempool_t * pool, session_finalizer_t fin,
        return new;
 }
 
-void
+struct rspamd_async_event *
 rspamd_session_add_event (struct rspamd_async_session *session,
        event_finalizer_t fin,
        void *user_data,
        GQuark subsystem)
 {
-       struct rspamd_async_event *new;
+       struct rspamd_async_event *new_event;
 
        if (session == NULL) {
                msg_err ("session is NULL");
-               return;
+               g_abort ();
+
+               /* Not reached */
+               return NULL;
        }
 
-       new = rspamd_mempool_alloc (session->pool,
+       new_event = rspamd_mempool_alloc (session->pool,
                        sizeof (struct rspamd_async_event));
-       new->fin = fin;
-       new->user_data = user_data;
-       new->subsystem = subsystem;
+       new_event->fin = fin;
+       new_event->user_data = user_data;
+       new_event->subsystem = subsystem;
 
        if (RSPAMD_SESSION_IS_WATCHING (session)) {
-               new->w = session->cur_watcher;
-               new->w->remain ++;
+               new_event->w = session->cur_watcher;
+               new_event->w->remain ++;
                msg_debug_session ("added event: %p, pending %d events, "
                                "subsystem: %s, watcher: %d",
                                user_data,
                                g_hash_table_size (session->events),
                                g_quark_to_string (subsystem),
-                               new->w->id);
+                               new_event->w->id);
        }
        else {
-               new->w = NULL;
+               new_event->w = NULL;
                msg_debug_session ("added event: %p, pending %d events, "
                                "subsystem: %s, no watcher!",
                                user_data,
@@ -165,7 +168,9 @@ rspamd_session_add_event (struct rspamd_async_session *session,
                                g_quark_to_string (subsystem));
        }
 
-       g_hash_table_insert (session->events, new, new);
+       g_hash_table_insert (session->events, new_event, new_event);
+
+       return new_event;
 }
 
 static inline void
index 1c9b49faf57d70f4411367d5c51ea979aff39d93..a0f99c0a56ea7b839c225cabc1bae21604e85217 100644 (file)
@@ -47,8 +47,9 @@ struct rspamd_async_session * rspamd_session_create (rspamd_mempool_t *pool,
  * @param user_data abstract user_data
  * @param forced unused
  */
-void rspamd_session_add_event (struct rspamd_async_session *session,
-       event_finalizer_t fin, gpointer user_data, GQuark subsystem);
+struct rspamd_async_event* rspamd_session_add_event (
+               struct rspamd_async_session *session,
+               event_finalizer_t fin, gpointer user_data, GQuark subsystem);
 
 /**
  * Remove normal event