winbind: Use standard tevent_context_init
authorVolker Lendecke <vl@samba.org>
Wed, 16 Jan 2013 11:00:00 +0000 (12:00 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 18 Jan 2013 17:16:58 +0000 (09:16 -0800)
This makes winbind use epoll instead of poll

Reviewed by: Jeremy Allison <jra@samba.org>

source3/winbindd/winbindd.c
source3/winbindd/winbindd.h
source3/winbindd/winbindd_proto.h

index 698c96cd539c57d7d248d0eadde3ea7929bb5eb8..ebaa080bc00b3cdfb964ba840874e5b25691f3a1 100644 (file)
@@ -49,14 +49,42 @@ static bool interactive = False;
 
 extern bool override_logfile;
 
+struct tevent_context *winbind_event_context(void)
+{
+       static struct tevent_context *ev = NULL;
+
+       if (ev != NULL) {
+               return ev;
+       }
+
+       /*
+        * Note we MUST use the NULL context here, not the autofree context,
+        * to avoid side effects in forked children exiting.
+        */
+       ev = tevent_context_init(NULL);
+       if (ev == NULL) {
+               smb_panic("Could not init winbindd's messaging context.\n");
+       }
+       return ev;
+}
+
 struct messaging_context *winbind_messaging_context(void)
 {
-       struct messaging_context *msg_ctx = server_messaging_context();
-       if (likely(msg_ctx != NULL)) {
-               return msg_ctx;
+       static struct messaging_context *msg = NULL;
+
+       if (msg != NULL) {
+               return msg;
+       }
+
+       /*
+        * Note we MUST use the NULL context here, not the autofree context,
+        * to avoid side effects in forked children exiting.
+        */
+       msg = messaging_init(NULL, winbind_event_context());
+       if (msg == NULL) {
+               smb_panic("Could not init winbindd's messaging context.\n");
        }
-       smb_panic("Could not init winbindd's messaging context.\n");
-       return NULL;
+       return msg;
 }
 
 /* Reload configuration */
index 33c7bbe5c684f886fd87ecb061387115c0df93e0..c01cac7ab3a0f1e6609f9075e873b304f995dabd 100644 (file)
@@ -396,6 +396,4 @@ struct WINBINDD_CCACHE_ENTRY {
 #define WINBINDD_PAM_AUTH_KRB5_RENEW_TIME 2592000 /* one month */
 #define DOM_SEQUENCE_NONE ((uint32)-1)
 
-#define winbind_event_context server_event_context
-
 #endif /* _WINBINDD_H */
index 44693d71dc30d9c877f536706bfb22534f594f8e..33b0f01f3de9e71de70c96c1123f3661735f4269 100644 (file)
@@ -34,6 +34,7 @@ bool winbindd_use_idmap_cache(void);
 bool winbindd_use_cache(void);
 const char *get_winbind_pipe_dir(void);
 char *get_winbind_priv_pipe_dir(void);
+struct tevent_context *winbind_event_context(void);
 int main(int argc, char **argv, char **envp);
 
 /* The following definitions come from winbindd/winbindd_ads.c  */