"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xinetd/connection.c" between
xinetd-2.3.15.tar.gz and xinetd-2.3.15.4.tar.xz

About: xinetd is a secure replacement for inetd, the internet services daemon (openSUSE fork).

connection.c  (xinetd-2.3.15):connection.c  (xinetd-2.3.15.4.tar.xz)
skipping to change at line 55 skipping to change at line 55
/* If it's a TCP socket, and we're set to wait, the accept is /* If it's a TCP socket, and we're set to wait, the accept is
* done by the child process. Don't set NEW_DESCRIPTOR, since * done by the child process. Don't set NEW_DESCRIPTOR, since
* there isn't one. The descriptor will be/was removed from * there isn't one. The descriptor will be/was removed from
* the descriptor set in svc_suspend and re-enabled in svc_resume. * the descriptor set in svc_suspend and re-enabled in svc_resume.
*/ */
if( SC_WAITS( scp ) ) { if( SC_WAITS( scp ) ) {
cp->co_descriptor = SVC_FD( sp ); cp->co_descriptor = SVC_FD( sp );
} else { } else {
cp->co_descriptor = accept( SVC_FD( sp ), &(cp->co_remote_address.sa), cp->co_descriptor = accept( SVC_FD( sp ), &(cp->co_remote_address.sa),
&sin_len ) ; &sin_len ) ;
if (cp->co_descriptor != -1) if ( cp->co_descriptor == -1 )
M_SET( cp->co_flags, COF_NEW_DESCRIPTOR ) ; {
} if ((errno == EMFILE) || (errno == ENFILE))
cps_service_stop(sp, "no available descriptors");
if ( cp->co_descriptor == -1 ) else
{ msg( LOG_ERR, func, "service %s, accept: %m", SVC_ID( sp ) ) ;
if ((errno == EMFILE) || (errno == ENFILE)) return( FAILED ) ;
cps_service_stop(sp, "no available descriptors"); }
else M_SET( cp->co_flags, COF_NEW_DESCRIPTOR ) ;
msg( LOG_ERR, func, "service %s, accept: %m", SVC_ID( sp ) ) ; M_SET( cp->co_flags, COF_HAVE_ADDRESS ) ;
return( FAILED ) ;
} }
if( SC_NODELAY( scp ) && (SC_PROTOVAL( scp ) == IPPROTO_TCP) ) if( SC_NODELAY( scp ) && (SC_PROTOVAL( scp ) == IPPROTO_TCP) )
if( setsockopt(SVC_FD(sp), IPPROTO_TCP, TCP_NODELAY, if( setsockopt(SVC_FD(sp), IPPROTO_TCP, TCP_NODELAY,
(char *)&on, sizeof( on ) ) < 0 ) (char *)&on, sizeof( on ) ) < 0 )
msg( LOG_WARNING, func, "service %s, setsockopt: %m", SVC_ID(sp)); msg( LOG_WARNING, func, "service %s, setsockopt: %m", SVC_ID(sp));
if( SC_KEEPALIVE( scp ) && (SC_PROTOVAL( scp ) == IPPROTO_TCP) ) if( SC_KEEPALIVE( scp ) && (SC_PROTOVAL( scp ) == IPPROTO_TCP) )
{ {
if( setsockopt(SVC_FD(sp), SOL_SOCKET, SO_KEEPALIVE, if( setsockopt(SVC_FD(sp), SOL_SOCKET, SO_KEEPALIVE,
skipping to change at line 90 skipping to change at line 89
if( SC_IPV6(scp) && !(SC_V6ONLY( scp )) && if( SC_IPV6(scp) && !(SC_V6ONLY( scp )) &&
(IN6_IS_ADDR_V4MAPPED(&cp->co_remote_address.sa_in6.sin6_addr) || (IN6_IS_ADDR_V4MAPPED(&cp->co_remote_address.sa_in6.sin6_addr) ||
IN6_IS_ADDR_V4COMPAT(&cp->co_remote_address.sa_in6.sin6_addr)) ) IN6_IS_ADDR_V4COMPAT(&cp->co_remote_address.sa_in6.sin6_addr)) )
{ {
int af = AF_INET; int af = AF_INET;
if( setsockopt(cp->co_descriptor, IPPROTO_IPV6, if( setsockopt(cp->co_descriptor, IPPROTO_IPV6,
IPV6_ADDRFORM, &af, sizeof( af ) ) ) { IPV6_ADDRFORM, &af, sizeof( af ) ) ) {
if( debug.on ) msg( LOG_WARNING, func, "service %s, IPV6_ADDRFORM se tsockopt() failed: %m", SVC_ID( sp) ); if( debug.on ) msg( LOG_WARNING, func, "service %s, IPV6_ADDRFORM se tsockopt() failed: %m", SVC_ID( sp) );
} }
} }
M_SET( cp->co_flags, COF_HAVE_ADDRESS ) ;
} }
else else
{ {
if ( SVC_SOCKET_TYPE( sp ) == SOCK_DGRAM ) if ( SVC_SOCKET_TYPE( sp ) == SOCK_DGRAM )
{ {
char t_ch ; char t_ch ;
ssize_t val; ssize_t val;
/* /*
* This trick is done to get the remote address. * This trick is done to get the remote address.
skipping to change at line 164 skipping to change at line 161
return( cp ) ; return( cp ) ;
} }
/* /*
* Release the specified connection. * Release the specified connection.
* Certain actions may be performed before doing this: * Certain actions may be performed before doing this:
* - drain of a single UDP packet if the socket type is SOCK_DGRAM * - drain of a single UDP packet if the socket type is SOCK_DGRAM
*/ */
void conn_free( connection_s *cp, int release_mem ) void conn_free( connection_s *cp, int release_mem )
{ {
struct service *sp = cp->co_sp ; struct service *sp ;
if( cp == NULL ) if( cp == NULL )
return; return;
if( debug.on ) if( debug.on )
msg( LOG_INFO, "conn_free", "freeing connection") ; msg( LOG_INFO, "conn_free", "freeing connection") ;
sp = cp->co_sp ;
if( (SVC_SOCKET_TYPE( sp ) == SOCK_DGRAM) && (SVC_IS_ACTIVE( sp )) ) if( (SVC_SOCKET_TYPE( sp ) == SOCK_DGRAM) && (SVC_IS_ACTIVE( sp )) )
drain( cp->co_descriptor ) ; drain( cp->co_descriptor ) ;
if ( SVC_RELE( sp ) == 0 ) { if ( SVC_RELE( sp ) == 0 ) {
pset_remove( SERVICES( ps ), sp ) ; pset_remove( SERVICES( ps ), sp ) ;
svc_release( sp ); svc_release( sp );
} }
cp->co_sp = NULL; cp->co_sp = NULL;
CONN_CLOSE( cp ) ; if ( CONN_DESCRIPTOR( cp ) > 0 )
CONN_CLOSE( cp ) ;
CLEAR( *cp ) ; CLEAR( *cp ) ;
if (release_mem) { if (release_mem) {
FREE_CONN( cp ) ; FREE_CONN( cp ) ;
} }
} }
/* This returns a pointer to a local static stack variable. /* This returns a pointer to a local static stack variable.
* The behavior is a remnant of inet_ntoa() behavior. * The behavior is a remnant of inet_ntoa() behavior.
*/ */
skipping to change at line 206 skipping to change at line 206
if( !M_IS_SET( (cp)->co_flags, COF_HAVE_ADDRESS ) ) if( !M_IS_SET( (cp)->co_flags, COF_HAVE_ADDRESS ) )
return "<no address>"; return "<no address>";
if( cp->co_remote_address.sa.sa_family == AF_INET ) if( cp->co_remote_address.sa.sa_family == AF_INET )
len = sizeof(struct sockaddr_in); len = sizeof(struct sockaddr_in);
else if( cp->co_remote_address.sa.sa_family == AF_INET6 ) else if( cp->co_remote_address.sa.sa_family == AF_INET6 )
len = sizeof(struct sockaddr_in6); len = sizeof(struct sockaddr_in6);
if( getnameinfo( &cp->co_remote_address.sa, len, if( getnameinfo( &cp->co_remote_address.sa, len,
name, NI_MAXHOST, NULL, 0, NI_NUMERICHOST ) ) { name, NI_MAXHOST, NULL, 0, NI_NUMERICHOST ) ) {
return "<no address>"; return "<invalid address>";
} }
return name; return name;
} }
void conn_dump( const connection_s *cp, int fd ) void conn_dump( const connection_s *cp, int fd )
{ {
const char *name = conn_addrstr( cp ); const char *name = conn_addrstr( cp );
tabprint( fd, 1, "service = %s\n", SVC_ID( cp->co_sp ) ) ; tabprint( fd, 1, "service = %s\n", SVC_ID( cp->co_sp ) ) ;
tabprint( fd, 1, "descriptor = %d\n", cp->co_descriptor ) ; tabprint( fd, 1, "descriptor = %d\n", cp->co_descriptor ) ;
#if defined(__GNUC__) && !defined(__arch64__) && !defined(__alpha__)
tabprint( fd, 1, "flags = %#llx\n", cp->co_flags ) ;
#else
tabprint( fd, 1, "flags = %#lx\n", cp->co_flags ) ; tabprint( fd, 1, "flags = %#lx\n", cp->co_flags ) ;
#endif
tabprint( fd, 1, "remote_address = %s,%d\n", name, tabprint( fd, 1, "remote_address = %s,%d\n", name,
ntohs( cp->co_remote_address.sa_in.sin_port ) ) ; ntohs( cp->co_remote_address.sa_in.sin_port ) ) ;
} }
 End of changes. 8 change blocks. 
22 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)