[Spread-cvs] commit: r654 - trunk/libspread-util/src

jschultz at spread.org jschultz at spread.org
Fri Jan 17 14:23:08 EST 2014


Author: jschultz
Date: 2014-01-17 14:23:08 -0500 (Fri, 17 Jan 2014)
New Revision: 654

Modified:
   trunk/libspread-util/src/alarm.c
   trunk/libspread-util/src/arch.c
Log:
Bugfix for alarm on windows for large log lines


Modified: trunk/libspread-util/src/alarm.c
===================================================================
--- trunk/libspread-util/src/alarm.c	2014-01-17 19:07:34 UTC (rev 653)
+++ trunk/libspread-util/src/alarm.c	2014-01-17 19:23:08 UTC (rev 654)
@@ -196,10 +196,12 @@
         }
 
         va_copy(ap_copy, ap);                               /* make a copy of param list in case of vsnprintf truncation */
-        msg_len  = vsnprintf(msg_ptr, MAX_ALARM_MESSAGE_BUF - tot_len, message, ap);
-        tot_len += msg_len;
+		if ((msg_len = vsnprintf(msg_ptr, MAX_ALARM_MESSAGE_BUF - tot_len, message, ap)) < 0) { /* failure; on Windows can be buffer too small */
+			msg_len = 4 * MAX_ALARM_MESSAGE_BUF;
+		}
+		tot_len += msg_len;
 
-        if (tot_len >= MAX_ALARM_MESSAGE_BUF) {             /* alarm string doesn't fit in buf; dynamically allocate big enough buffer */
+        if (tot_len >= MAX_ALARM_MESSAGE_BUF) {             /* failure; try dynamically allocating a bigger buffer */
 
             if ((alloc_buf = (char*) malloc(sizeof(Alarm_Warning_Alloc) - 1 + tot_len + 1)) != NULL) {
 
@@ -212,8 +214,9 @@
 		tot_len += ts_len;
 
                 msg_ptr  = ts_ptr + ts_len;
-                tmp      = vsnprintf(msg_ptr, msg_len + 1, message, ap_copy);             /* write msg after timestamp */
-                assert(tmp == msg_len);
+				if ((tmp = vsnprintf(msg_ptr, msg_len + 1, message, ap_copy)) < 0) {             /* write msg after timestamp */
+					tmp = msg_len;
+				}
                 msg_len  = tmp;
 		tot_len += msg_len;
 

Modified: trunk/libspread-util/src/arch.c
===================================================================
--- trunk/libspread-util/src/arch.c	2014-01-17 19:07:34 UTC (rev 653)
+++ trunk/libspread-util/src/arch.c	2014-01-17 19:23:08 UTC (rev 654)
@@ -68,11 +68,11 @@
         case WSAENETDOWN:
             return "WSAENETDOWN: The network subsystem has failed.";
         case WSAEACCES:
-            return "WSAEACCES: The requested address is a broadcast address, but the appropriate flag was not set. Call setsockopt with the SO_BROADCAST parameter to allow the use of the broadcast address.";
+            return "WSAEACCES: The requested address is a broadcast address. Call setsockopt with the SO_BROADCAST parameter to allow the use of the broadcast address.";
         case WSAEINTR:
-            return "WSAEINTR: A blocking Windows Sockets 1.1 call was canceled through WSACancelBlockingCall.";
+            return "WSAEINTR: A blocking Windows Sockets call was canceled through WSACancelBlockingCall.";
         case WSAEINPROGRESS:
-            return "WSAEINPROGRESS: A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.";
+            return "WSAEINPROGRESS: A blocking Windows Sockets call is in progress, or the service provider is still processing a callback function.";
         case WSAEFAULT:
             return "WSAEFAULT: The buf parameter is not completely contained in a valid part of the user address space." ;
         case WSAENETRESET:
@@ -84,7 +84,7 @@
         case WSAENOTSOCK:
             return "WSAENOTSOCK: The descriptor is not a socket.";
         case WSAEOPNOTSUPP:
-            return "WSAEOPNOTSUPP: MSG_OOB was specified, but the socket is not stream-style such as type SOCK_STREAM, out-of-band data is not supported in the communication domain associated with this socket, or the socket is unidirectional and supports only receive operations.";
+            return "WSAEOPNOTSUPP: Operation not supported.";
         case WSAESHUTDOWN:
             return "WSAESHUTDOWN The socket has been shut down; it is not possible to send on a socket after shutdown has been invoked with how set to SD_SEND or SD_BOTH.";
         case WSAEWOULDBLOCK:
@@ -98,7 +98,7 @@
         case WSAECONNABORTED:
             return "WSAECONNABORTED: The virtual circuit was terminated due to a time-out or other failure. The application should close the socket as it is no longer usable.";
         case WSAECONNRESET:
-            return "WSAECONNRESET: The virtual circuit was reset by the remote side executing a hard or abortive close. For UPD sockets, the remote host was unable to deliver a previously sent UDP datagram and responded with a Port Unreachable ICMP packet. The application should close the socket as it is no longer usable.";
+            return "WSAECONNRESET: The connection was reset by the remote side executing a hard or abortive close. For a UDP socket, the remote host responded with a Port Unreachable ICMP packet.";
         case WSAETIMEDOUT:
             return "WSAETIMEDOUT: The connection has been dropped, because of a network failure or because the system on the other end went down without notice.";
         default:




More information about the Spread-cvs mailing list