[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Async problems
ldap_result() doesn't seem to behave very nicely when trying to use it
asynchronously. I call it whenever poll() says there's new data in ldap
fd, but if timeout is anything less than 1 second, it doesn't work
right. And 1 second timeout is too much since my process is doing other
things as well.
It looks like the problem is that first time when calling it,
try_read1msg() finds a reply to non-search request and returns -2
(result.c line 695). So, ldap_request() then checks if it's spent enough
time, with <1sec timeout it has and doesn't try to read the data until
later when new data comes. Then it gets a reply to previous request and
the new one is stuck..
I guess the real problem is that both of the requests are read into
buffer, but only one of them is actually handled. So, how about always
parsing the requests until valid one is found or buffer is empty?
Included patch seems to work with me.
But could this be fixed in some way that would work with older versions
too?
--- result.c.old 2003-02-01 01:37:48.000000000 +0200
+++ result.c 2003-02-01 01:38:28.000000000 +0200
@@ -303,8 +303,14 @@
LDAP_CONNST_CONNECTED &&
ldap_is_read_ready( ld,
lc->lconn_sb )) {
- rc = try_read1msg( ld, msgid, all,
- lc->lconn_sb, lc, result );
+
+ do {
+ rc = try_read1msg( ld, msgid, all,
+ lc->lconn_sb, lc, result );
+ } while ( rc == -2 &&
+ ber_sockbuf_ctrl( lc->lconn_sb,
+ LBER_SB_OPT_DATA_READY, NULL ) );
+
}
}
}