Commit edb803d1 authored by Pekka Pessi's avatar Pekka Pessi

su_port: fixed su_port_register() with more than SU_WAIT_MIN entries.

darcs-hash:20061011132330-65a35-3e2a10ed9f65db27fe58a6fbcdb259176498b7ec.gz
parent cb55f034
......@@ -692,7 +692,10 @@ int su_port_register(su_port_t *self,
if (indices) {
self->sup_indices = indices;
for (i = self->sup_size_waits; i <= size; i++)
if (self->sup_size_waits == 0)
indices[0] = -1;
for (i = self->sup_size_waits + 1; i <= size; i++)
indices[i] = -1 - i;
}
......
......@@ -54,7 +54,7 @@ int tstflags;
char const *name = "torture_su_port";
int const N0 = SU_HAVE_MBOX, N = 16, I = 17;
int const N0 = SU_HAVE_MBOX, N = 128, I = 129;
int test_sup_indices(su_port_t const *port)
{
......@@ -112,7 +112,7 @@ static int callback(su_root_magic_t *magic,
assert(magic);
if (i < 0 || i > 16)
if (i <= 0 || i > I)
return ++magic->error;
magic->wakeups[i]++;
......@@ -159,10 +159,10 @@ int test_register(void)
su_port_t *port;
su_sockaddr_t su[1];
int i;
int sockets[32] = { 0 };
int reg[32] = { 0 };
int wakeups[32] = { 0 };
su_wait_t wait[32];
int sockets[256] = { 0 };
int reg[256] = { 0 };
int wakeups[256] = { 0 };
su_wait_t wait[256];
su_root_magic_t magic[1] = {{ 0, sockets, reg, wakeups }};
su_root_t root[1] = {{ sizeof root, magic }};
......@@ -189,7 +189,8 @@ int test_register(void)
for (i = N0; i < N; i++) {
sockets[i] = su_socket(AF_INET, SOCK_DGRAM, 0); TEST_1(sockets[i] != -1);
TEST(bind(sockets[i], &su->su_sa, sizeof su->su_sin), 0);
if (bind(sockets[i], &su->su_sa, sizeof su->su_sin) != 0)
perror("bind"), assert(0);
TEST(su_wait_create(wait + i, sockets[i], SU_WAIT_IN), 0);
......@@ -226,6 +227,7 @@ int test_register(void)
TEST(port->sup_indices[0], -I);
#if 0
#if HAVE_EPOLL
/* With epoll we do not bother to prioritize the wait list */
if (port->sup_epoll != -1) {
......@@ -250,6 +252,7 @@ int test_register(void)
TEST_M(wait + 3, port->sup_waits + 1, sizeof wait[0]);
TEST_M(wait + 1, port->sup_waits + 0, sizeof wait[0]);
}
#endif
TEST_1(test_sup_indices(port));
TEST(test_wakeup(port, magic), 0);
......@@ -268,7 +271,7 @@ int test_register(void)
TEST(su_port_deregister(port, 0), -1);
TEST(su_port_deregister(port, -1), -1);
TEST(su_port_deregister(port, 20), -1);
TEST(su_port_deregister(port, 130), -1);
TEST_1(test_sup_indices(port));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment