mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-01 12:39:35 -05:00
Provide set_nonblock code which acts upon ber_socket_t and use this
as in sockbuf_set_nonblock code. Allows -llber and -lldap to share a common implementation.
This commit is contained in:
parent
bd9323efc3
commit
7275861039
2 changed files with 24 additions and 13 deletions
|
|
@ -270,5 +270,7 @@ ber_pvt_sb_udp_set_dst LDAP_P((Sockbuf *sb, void *addr ));
|
|||
LDAP_F( void * )
|
||||
ber_pvt_sb_udp_get_src LDAP_P((Sockbuf *sb ));
|
||||
|
||||
LDAP_F( int )
|
||||
ber_pvt_socket_set_nonblock LDAP_P(( ber_socket_t sd, int nb ));
|
||||
|
||||
#endif /* _LBER_INT_H */
|
||||
|
|
|
|||
|
|
@ -644,6 +644,23 @@ int ber_pvt_sb_set_readahead( Sockbuf *sb, int rh )
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ber_pvt_socket_set_nonblock( ber_socket_t sd, int nb )
|
||||
{
|
||||
#if HAVE_FCNTL
|
||||
int flags = fcntl(ber_pvt_sb_get_desc(sb), F_GETFL);
|
||||
if( nb ) {
|
||||
flags |= O_NONBLOCK;
|
||||
} else {
|
||||
flags &= ~O_NONBLOCK;
|
||||
}
|
||||
return fcntl( ber_pvt_sb_get_desc(sb), F_SETFL, flags );
|
||||
|
||||
#elif defined( FIONBIO )
|
||||
ioctl_t status = nb ? 1 : 0;
|
||||
return ioctl( sd, FIONBIO, &status );
|
||||
#endif
|
||||
}
|
||||
|
||||
#define USE_NONBLOCK
|
||||
#ifdef USE_NONBLOCK
|
||||
int ber_pvt_sb_set_nonblock( Sockbuf *sb, int nb )
|
||||
|
|
@ -662,19 +679,11 @@ int ber_pvt_sb_set_nonblock( Sockbuf *sb, int nb )
|
|||
sb->sb_read_ahead = 0;
|
||||
#endif
|
||||
}
|
||||
if (ber_pvt_sb_in_use(sb)) {
|
||||
#if HAVE_FCNTL
|
||||
int flags = fcntl(ber_pvt_sb_get_desc(sb), F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
return fcntl(ber_pvt_sb_get_desc(sb), F_SETFL, flags);
|
||||
|
||||
#elif defined( FIONBIO )
|
||||
/* WINSOCK requires the status to be a long */
|
||||
ioctl_t status = (nb!=0);
|
||||
return ioctl( ber_pvt_sb_get_desc(sb), FIONBIO, &status );
|
||||
#endif /* FIONBIO */
|
||||
}
|
||||
return 0;
|
||||
if (ber_pvt_sb_in_use(sb)) {
|
||||
return ber_pvt_socket_set_nonblock(
|
||||
ber_pvt_sb_get_desc(sb), nb );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue