Minor documentation updates.
[metaproxy-moved-to-github.git] / src / thread_pool_observer.cpp
index f018bf9..ded50d7 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Metaproxy.
-   Copyright (C) 2005-2008 Index Data
+   Copyright (C) 2005-2012 Index Data
 
 Metaproxy is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <unistd.h>
 #endif
 
+#ifdef WIN32
+#include <windows.h>
+#include <winsock.h>
+#endif
 #include <boost/thread/thread.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread/condition.hpp>
@@ -124,7 +128,16 @@ void ThreadPoolSocketObserver::socketNotify(int event)
 #ifdef WIN32
         recv(m_p->m_pipe.read_fd(), buf, 1, 0);
 #else
-        read(m_p->m_pipe.read_fd(), buf, 1);
+        ssize_t r = read(m_p->m_pipe.read_fd(), buf, 1);
+        if (r != 1)
+        {
+            if (r == (ssize_t) (-1))
+                yaz_log(YLOG_WARN|YLOG_ERRNO,
+                        "ThreadPoolSocketObserver::socketNotify. read fail");
+            else
+                yaz_log(YLOG_WARN,
+                        "ThreadPoolSocketObserver::socketNotify. read returned 0");
+        }
 #endif
         IThreadPoolMsg *out;
         {
@@ -160,7 +173,16 @@ void ThreadPoolSocketObserver::run(void *p)
 #ifdef WIN32
             send(m_p->m_pipe.write_fd(), "", 1, 0);
 #else
-            write(m_p->m_pipe.write_fd(), "", 1);
+            ssize_t r = write(m_p->m_pipe.write_fd(), "", 1);
+            if (r != 1)
+            {
+                if (r == (ssize_t) (-1))
+                    yaz_log(YLOG_WARN|YLOG_ERRNO,
+                            "ThreadPoolSocketObserver::run. write fail");
+                else
+                    yaz_log(YLOG_WARN,
+                            "ThreadPoolSocketObserver::run. write returned 0");
+            }
 #endif
         }
     }