summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7de0042)
Clean up: The makesock() function can become static since it is only used in
rpcmisc.c, where it is defined. Fix some minor nits while we're in the area:
o Move it so we can remove it's forward declaration.
o Get rid of unneeded newlines in the xlog() format strings.
o Use htonl(INADDR_ANY) instead of INADDR_ANY to initialize sin_addr.
Should make no run-time difference, but is slightly more proper,
as the standard definition of INADDR_ANY is in host byte-order.
o Remove the parentheses in the "return" statements.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-int makesock(int port, int proto);
void rpc_init(char *name, int prog, int vers,
void (*dispatch)(struct svc_req *, SVCXPRT *),
int defport);
void rpc_init(char *name, int prog, int vers,
void (*dispatch)(struct svc_req *, SVCXPRT *),
int defport);
#endif
static void closedown(int sig);
#endif
static void closedown(int sig);
-int makesock(int port, int proto);
+static int makesock(int port, int proto);
#define _RPCSVC_CLOSEDOWN 120
int _rpcpmstart = 0;
#define _RPCSVC_CLOSEDOWN 120
int _rpcpmstart = 0;
(void) alarm(_RPCSVC_CLOSEDOWN);
}
(void) alarm(_RPCSVC_CLOSEDOWN);
}
-int makesock(int port, int proto)
+/*
+ * Create listener socket for a given port
+ *
+ * Return an open network socket on success; otherwise return -1
+ * if some error occurs.
+ */
+static int
+makesock(int port, int proto)
{
struct sockaddr_in sin;
{
struct sockaddr_in sin;
- int s;
- int sock_type;
- int val;
+ int sock, sock_type, val;
sock_type = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
sock_type = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
- s = socket(AF_INET, sock_type, proto);
- if (s < 0) {
- xlog(L_FATAL, "Could not make a socket: %s\n",
+ sock = socket(AF_INET, sock_type, proto);
+ if (sock < 0) {
+ xlog(L_FATAL, "Could not make a socket: %s",
}
memset((char *) &sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
}
memset((char *) &sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = htons(port);
val = 1;
if (proto == IPPROTO_TCP)
sin.sin_port = htons(port);
val = 1;
if (proto == IPPROTO_TCP)
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
- xlog(L_ERROR, "setsockopt failed: %s\n",
+ xlog(L_ERROR, "setsockopt failed: %s",
- if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
- xlog(L_FATAL, "Could not bind name to socket: %s\n",
+ if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
+ xlog(L_FATAL, "Could not bind name to socket: %s",