changeset 53:7b98da167a0b

Improved error handling.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 07 Nov 2008 22:17:44 +0200
parents 8d9c065241b7
children f6666e7c1a48
files nnchat.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/nnchat.c	Fri Nov 07 22:17:33 2008 +0200
+++ b/nnchat.c	Fri Nov 07 22:17:44 2008 +0200
@@ -372,7 +372,7 @@
 	wrefresh(editWin);
 }
 
-int openConnection(struct in_addr *addr, int port)
+int openConnection(struct in_addr *addr, const int port)
 {
 	struct sockaddr_in tmpAddr;
 	int sock = -1;
@@ -400,7 +400,7 @@
 }
 
 
-void closeConnection(int sock)
+void closeConnection(const int sock)
 {
 	if (sock >= 0) {
 		close(sock);
@@ -408,7 +408,7 @@
 }
 
 
-BOOL sendToSocket(int sock, char *buf, const size_t bufLen)
+BOOL sendToSocket(const int sock, char *buf, const size_t bufLen)
 {
 	size_t bufLeft = bufLen;
 	char *bufPtr = buf;
@@ -1305,9 +1305,10 @@
 		tv.tv_usec = SET_DELAY_USEC;
 		tmpfds = sockfds;
 		if ((result = select(tmpSocket+1, &tmpfds, NULL, NULL, &tv)) == -1) {
-			printMsg("Error occured in select(sockfds): %s\n",
-				strerror(errno));
-			isError = TRUE;
+			if (errno != EINTR && errno != ERESTART) {
+				printMsg("Error occured in select(sockfds): %d, %s\n", errno, strerror(errno));
+				isError = TRUE;
+			}
 		} else if (FD_ISSET(tmpSocket, &tmpfds)) {
 			ssize_t gotBuf;
 			char tmpBuf[8192];