diff --git a/nsock/src/netutils.c b/nsock/src/netutils.c index fa11d1bf9..f38aed363 100644 --- a/nsock/src/netutils.c +++ b/nsock/src/netutils.c @@ -94,10 +94,10 @@ static int netutils_debugging = 0; * process and return that maximum value (note -- you better not actually open * this many -- stdin, stdout, other files opened by libraries you use, etc. all * count toward this limit. Leave a little slack */ -int maximize_fdlimit(void) { +int maximize_fdlimit(void) { #ifndef WIN32 - struct rlimit r; + struct rlimit r; static int maxfds = -1; if (maxfds > 0) @@ -146,12 +146,12 @@ int maximize_fdlimit(void) { #if HAVE_SYS_UN_H /* Get the UNIX domain socket path or empty string if the address family != AF_UNIX. */ -const char *get_unixsock_path(const struct sockaddr_storage *addr) -{ +const char *get_unixsock_path(const struct sockaddr_storage *addr) { + struct sockaddr_un *su = (struct sockaddr_un *)addr; + if (!addr || addr->ss_family != AF_UNIX) return ""; - struct sockaddr_un *su = (struct sockaddr_un *)addr; return (const char *)su->sun_path; } #endif @@ -160,8 +160,7 @@ const char *get_unixsock_path(const struct sockaddr_storage *addr) * In case we have support for UNIX domain sockets, function returns * string containing path to UNIX socket if the address family is AF_UNIX, * otherwise it returns string containing "
:". */ -char *get_peeraddr_string(const msiod *iod) -{ +char *get_peeraddr_string(const msiod *iod) { static char buffer[PEER_STR_LEN]; #if HAVE_SYS_UN_H diff --git a/nsock/src/nsock_event.c b/nsock/src/nsock_event.c index 322bddc25..138cacc56 100644 --- a/nsock/src/nsock_event.c +++ b/nsock/src/nsock_event.c @@ -438,12 +438,12 @@ msevent *msevent_new(mspool *nsp, enum nse_type type, msiod *msiod, int timeout_ nse->iod = msiod; nse->handler = handler; nse->userdata = userdata; - nse->time_created = nsock_tod; - if (nse->iod == NULL) - nsock_log_debug(nsp, "msevent_new (IOD #NULL) (EID #%li)", nse->id); - else - nsock_log_debug(nsp, "msevent_new (IOD #%li) (EID #%li)", nse->iod->id, nse->id); + if (nse->iod == NULL) + nsock_log_debug(nsp, "msevent_new (IOD #NULL) (EID #%li)", nse->id); + else + nsock_log_debug(nsp, "msevent_new (IOD #%li) (EID #%li)", nse->iod->id, + nse->id); return nse; } diff --git a/nsock/src/nsock_internal.h b/nsock/src/nsock_internal.h index 710e21dbd..4343ef4be 100644 --- a/nsock/src/nsock_internal.h +++ b/nsock/src/nsock_internal.h @@ -312,7 +312,6 @@ typedef struct { /* nsock_event_t handles a single event. Its ID is generally returned when the * event is created, and the event is included in callbacks */ typedef struct { - /* Every event has an ID which is unique for a given nsock unless you blow * through more than 500,000,000 events */ nsock_event_id id; @@ -340,8 +339,6 @@ typedef struct { /* If we return a status of NSE_STATUS_ERROR, this must be set */ int errnum; - int eof; - /* The nsock I/O descriptor related to event (if applicable) */ msiod *iod; @@ -355,9 +352,8 @@ typedef struct { * event_done is nonzero. Used when event is finished at unexpected time and * we want to dispatch it later to avoid duplicating stat update code and all * that other crap */ - int event_done; - - struct timeval time_created; + unsigned int event_done: 1; + unsigned int eof: 1; } msevent;