[PVFS2-CVS] commit by rbross in pvfs2/src/io/bmi/bmi_tcp: sockio.c

CVS commit program cvs at parl.clemson.edu
Wed Feb 9 16:00:20 EST 2005


Update of /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp
In directory parlweb:/tmp/cvs-serv29997/src/io/bmi/bmi_tcp

Modified Files:
	sockio.c 
Log Message:

Removed use of getprotobyname(); I don't think anyone cares, and it will fix
things on scyld, and eliminates an issue on BG/L.  Also test for netdb.


Index: sockio.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/sockio.c,v
diff -p -u -r1.14 -r1.15
--- sockio.c	28 Jul 2004 14:32:40 -0000	1.14
+++ sockio.c	9 Feb 2005 21:00:20 -0000	1.15
@@ -4,6 +4,8 @@
  * See COPYING in top-level directory.
  */
 
+#include "pvfs2-config.h"
+
 #include <unistd.h>
 #include <errno.h>
 #include <stdio.h>
@@ -14,7 +16,9 @@
 #include <fcntl.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#ifdef HAVE_NETDB_H
 #include <netdb.h>
+#endif
 #include <sys/poll.h>
 #include <sys/uio.h>
 
@@ -31,19 +35,7 @@
 
 int BMI_sockio_new_sock()
 {
-    static int p_num = -1;	/* set to tcp protocol # on first call */
-    struct protoent *pep;
-
-    if (p_num == -1)
-    {
-	if ((pep = getprotobyname("tcp")) == NULL)
-	{
-	    perror("Kernel does not support tcp");
-	    return (-1);
-	}
-	p_num = pep->p_proto;
-    }
-    return (socket(AF_INET, SOCK_STREAM, p_num));
+    return(socket(AF_INET, SOCK_STREAM, IPPROTO_TCP));
 }
 
 int BMI_sockio_bind_sock(int sockd,
@@ -374,10 +366,7 @@ int BMI_sockio_set_tcpopt(int s,
 	       int optname,
 	       int val)
 {
-    struct protoent* p = getprotobyname("tcp");
-    if(!p)
-	return(-1);
-    if (setsockopt(s, p->p_proto, optname, &val, sizeof(val)) == -1)
+    if (setsockopt(s, IPPROTO_TCP, optname, &val, sizeof(val)) == -1)
 	return (-1);
     else
 	return (val);



More information about the PVFS2-CVS mailing list