Skip to content
This repository
Browse code

Wait for sockets to start before returning from Publisher.Start

Otherwise we might loose some session started messages
  • Loading branch information...
commit 78d26fbfaf00dc98db846edcb593c0843a50a540 1 parent 8ac7eda
Seif Attar authored February 25, 2012
12  src/NHibernate.ZMQLogPublisher/Publisher.cs
@@ -15,11 +15,14 @@ public class Publisher
15 15
 
16 16
         public static void Start()
17 17
         {
18  
-            running = true;
19 18
             context = new Context(1);
20 19
             
21 20
             new Task(ListenAndPublishLogMessages).Start();
22 21
 
  22
+            while(!running)
  23
+            {
  24
+            }
  25
+
23 26
             LoggerProvider.SetLoggersFactory(new ZmqLoggerFactory(context));
24 27
         }
25 28
 
@@ -38,11 +41,12 @@ private static void ListenAndPublishLogMessages()
38 41
 
39 42
                 loggers.Bind("inproc://loggers");
40 43
                 loggers.Linger = 0;
41  
-
  44
+                running = true;
  45
+                
42 46
                 while (running)
43 47
                 {
44  
-                    var logMessage = loggers.Recv(Encoding.Unicode);
45  
-
  48
+                    var logMessage = loggers.Recv(Encoding.Unicode, timeout: 1000);
  49
+                    if(logMessage != null)
46 50
                     publisher.Send(logMessage, Encoding.Unicode);
47 51
                 }
48 52
             }

0 notes on commit 78d26fb

Please sign in to comment.
Something went wrong with that request. Please try again.