[xiph-cvs] cvs commit: net sock.c

Michael Smith msmith at xiph.org
Wed Jul 31 08:00:12 PDT 2002



msmith      02/07/31 08:00:12

  Modified:    src      config.c config.h main.c
               .        sock.c
  Log:
  Config fixes for when parsing fails
  Don't needlessly call getsockopt() all the time (it's a system call, hence
  expensive)

Revision  Changes    Path
1.8       +1 -1      icecast/src/config.c

Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- config.c	2002/06/29 04:29:37	1.7
+++ config.c	2002/07/31 15:00:11	1.8
@@ -89,7 +89,7 @@
 
         doc = xmlParseFile(_config_filename);
         if (doc == NULL) {
-		return -1;
+		return CONFIG_EPARSE;
         }
 
         node = xmlDocGetRootElement(doc);

<p><p>1.4       +1 -0      icecast/src/config.h

Index: config.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- config.h	2002/05/14 11:06:54	1.3
+++ config.h	2002/07/31 15:00:11	1.4
@@ -4,6 +4,7 @@
 #define CONFIG_EINSANE -1
 #define CONFIG_ENOROOT -2
 #define CONFIG_EBADROOT -3
+#define CONFIG_EPARSE -4
 
 typedef struct ice_config_dir_tag
 {

<p><p>1.11      +2 -0      icecast/src/main.c

Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/main.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- main.c	2002/07/23 15:15:11	1.10
+++ main.c	2002/07/31 15:00:11	1.11
@@ -277,6 +277,8 @@
                                 fprintf(stderr, "parse error\n");
                                 break;
                         }
+            _shutdown_subsystems();
+            return 1;
                 }
         } else if (res == -1) {
                 _print_usage();

<p><p>1.6       +6 -6      net/sock.c

Index: sock.c
===================================================================
RCS file: /usr/local/cvsroot/net/sock.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- sock.c	2002/03/22 21:44:29	1.5
+++ sock.c	2002/07/31 15:00:12	1.6
@@ -214,9 +214,9 @@
                 return SOCK_ERROR;
         } else if (len <= 0) {
                 return SOCK_ERROR;
-	} else if (!sock_valid_socket(sock)) {
+	} /*else if (!sock_valid_socket(sock)) {
                 return SOCK_ERROR;
-	}
+	} */
 
         return send(sock, buff, len, 0);
 }
@@ -251,9 +251,8 @@
 
 int sock_read_bytes(sock_t sock, char *buff, const int len)
 {
-//	int ret;
 
-	if (!sock_valid_socket(sock)) return 0;
+	/*if (!sock_valid_socket(sock)) return 0; */
         if (!buff) return 0;
         if (len <= 0) return 0;
 
@@ -273,9 +272,9 @@
         char c = '\0';
         int read_bytes, pos;
   
-	if (!sock_valid_socket(sock)) {
+	/*if (!sock_valid_socket(sock)) {
                 return 0;
-	} else if (!buff) {
+	} else*/ if (!buff) {
                 return 0;
         } else if (len <= 0) {
                 return 0;
@@ -490,6 +489,7 @@
         ret = accept(serversock, (struct sockaddr *)&sin, &slen);
 
         if (ret >= 0 && ip != NULL) {
+        // inet_ntoa is not reentrant, we should protect this
                 strncpy(ip, inet_ntoa(sin.sin_addr), len);
                 sock_set_nolinger(ret);
                 sock_set_keepalive(ret);

<p><p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list