mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Move the "function to getsockname() on a listener" to regress_testutils
This reverts commit fab50488fcb741884ccdfa7b83643eac3e5c9cbf. The function was, on reflection, not important enough to break the feature freeze, since it's trivial to build on your own.
This commit is contained in:
parent
c51826ff50
commit
42090072c1
@ -112,11 +112,6 @@ struct event_base *evconnlistener_get_base(struct evconnlistener *lev);
|
||||
/** Return the socket that an evconnlistner is listening on. */
|
||||
evutil_socket_t evconnlistener_get_fd(struct evconnlistener *lev);
|
||||
|
||||
/** Set ss to the address that an evconnlistner is listening on; returns 0
|
||||
* on success, -1 on failure. */
|
||||
int evconnlistener_get_address(struct evconnlistener *lev,
|
||||
struct sockaddr *sa, ev_socklen_t *socklen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
10
listener.c
10
listener.c
@ -261,16 +261,6 @@ event_listener_getfd(struct evconnlistener *lev)
|
||||
return event_get_fd(&lev_e->listener);
|
||||
}
|
||||
|
||||
int
|
||||
evconnlistener_get_address(struct evconnlistener *lev,
|
||||
struct sockaddr *sa, ev_socklen_t *socklen)
|
||||
{
|
||||
evutil_socket_t s = evconnlistener_get_fd(lev);
|
||||
if (s <= 0)
|
||||
return -1;
|
||||
return getsockname(s, sa, socklen);
|
||||
}
|
||||
|
||||
struct event_base *
|
||||
evconnlistener_get_base(struct evconnlistener *lev)
|
||||
{
|
||||
|
@ -79,6 +79,7 @@
|
||||
#endif
|
||||
|
||||
#include "regress.h"
|
||||
#include "regress_testutils.h"
|
||||
|
||||
/*
|
||||
* simple bufferevent test
|
||||
@ -508,7 +509,7 @@ test_bufferevent_connect(void *arg)
|
||||
|
||||
sa = (struct sockaddr *)&ss;
|
||||
slen = sizeof(ss);
|
||||
if (evconnlistener_get_address(lev, sa, &slen) < 0) {
|
||||
if (regress_get_listener_addr(lev, sa, &slen) < 0) {
|
||||
tt_abort_perror("getsockname");
|
||||
}
|
||||
|
||||
|
@ -183,3 +183,13 @@ regress_dnsserver(struct event_base *base, ev_uint16_t *port,
|
||||
regress_dns_server_cb, search_table);
|
||||
return dns_port != NULL;
|
||||
}
|
||||
|
||||
int
|
||||
regress_get_listener_addr(struct evconnlistener *lev,
|
||||
struct sockaddr *sa, ev_socklen_t *socklen)
|
||||
{
|
||||
evutil_socket_t s = evconnlistener_get_fd(lev);
|
||||
if (s <= 0)
|
||||
return -1;
|
||||
return getsockname(s, sa, socklen);
|
||||
}
|
||||
|
@ -57,5 +57,10 @@ int regress_dnsserver(struct event_base *base, ev_uint16_t *port,
|
||||
/* clean up the global dns server resources */
|
||||
void regress_clean_dnsserver(void);
|
||||
|
||||
struct evconnlistener;
|
||||
struct sockaddr;
|
||||
int regress_get_listener_addr(struct evconnlistener *lev,
|
||||
struct sockaddr *sa, ev_socklen_t *socklen);
|
||||
|
||||
#endif /* _TESTUTILS_H */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user