OSDN Git Service

* fhandler_socket.cc (send_internal): Don't split datagram messages
authorcorinna <corinna>
Thu, 3 Dec 2009 00:23:02 +0000 (00:23 +0000)
committercorinna <corinna>
Thu, 3 Dec 2009 00:23:02 +0000 (00:23 +0000)
into pieces.

* syslog.cc (vsyslog): Set default facility to LOG_USER if it hasn't
been set yet.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/syslog.cc

index 4be550c..91964d3 100644 (file)
@@ -1,3 +1,11 @@
+2009-12-02  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_socket.cc (send_internal): Don't split datagram messages
+       into pieces.
+
+       * syslog.cc (vsyslog): Set default facility to LOG_USER if it hasn't
+       been set yet.
+
 2009-12-01  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler_registry.cc (fhandler_registry::open): Mark /proc/registry
index 5f22d7d..98a64ae 100644 (file)
@@ -1613,8 +1613,10 @@ fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags)
   for (DWORD i = 0; i < wsamsg->dwBufferCount;
        off >= wsamsg->lpBuffers[i].len && (++i, off = 0))
     {
-      /* FIXME?  Use the same technique in call to WSASendMsg? */
-      if (!use_sendmsg)
+      /* CV 2009-12-02: Don't split datagram messages. */
+      /* FIXME: Look for a way to split a message into the least number of
+               pieces to minimize the number of WsaSendTo calls. */
+      if (get_socket_type () == SOCK_STREAM)
        {
          buf.buf = wsamsg->lpBuffers[i].buf + off;
          buf.len = wsamsg->lpBuffers[i].len - off;
@@ -1627,9 +1629,13 @@ fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags)
        {
          if (use_sendmsg)
            res = WSASendMsg (get_socket (), wsamsg, flags, &ret, NULL, NULL);
-         else
+         else if (get_socket_type () == SOCK_STREAM)
            res = WSASendTo (get_socket (), &buf, 1, &ret, flags,
                             wsamsg->name, wsamsg->namelen, NULL, NULL);
+         else
+           res = WSASendTo (get_socket (), wsamsg->lpBuffers,
+                            wsamsg->dwBufferCount, &ret, flags,
+                            wsamsg->name, wsamsg->namelen, NULL, NULL);
          if (res && (err = WSAGetLastError ()) == WSAEWOULDBLOCK)
            {
              LOCK_EVENTS;
@@ -1644,7 +1650,7 @@ fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags)
        {
          off += ret;
          sum += ret;
-         if (use_sendmsg)
+         if (get_socket_type () != SOCK_STREAM)
            break;
        }
       else if (is_nonblocking () || err != WSAEWOULDBLOCK)
index fe76b50..b27f0e7 100644 (file)
@@ -1,7 +1,7 @@
 /* syslog.cc
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2006, 2007 Red Hat, Inc.
+   2006, 2007, 2009 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -275,6 +275,10 @@ vsyslog (int priority, const char *message, va_list ap)
       return;
     }
 
+  /* Set default facility to LOG_USER if not yet set via openlog. */
+  if (!_my_tls.locals.process_facility)
+    _my_tls.locals.process_facility = LOG_USER;
+
   /* Add default facility if not in the given priority. */
   if (!(priority & LOG_FACMASK))
     priority |= _my_tls.locals.process_facility;