Re: dbmail-3.2.0 double lock?

Sergej Pupykin <[email protected]> Wed, 03 Sep 2014 13:15:57 +0400
Newsgroups gmane.mail.imap.dbmail.devel
Message-ID <87ha0p83oy.wl%[email protected]>
At Tue, 02 Sep 2014 21:07:50 +0400,
Sergej Pupykin <[email protected]> wrote:
> ci_read_cb() calls client->cb_error() under PLOCK(client->lock).
>
> cb_error == client_error_cb, which also calls client->PLOCK(client->lock).
>
> Can it hangs here in case of error?

I've made completely incorrect fix, which works and proofs that this
is the bug:

--- dbmail-3.2.0/src/clientbase.c	2014-08-23 17:01:38.000000000 +0400
+++ dbmail-3.2.0.my/src/clientbase.c	2014-09-02 21:22:01.075125889 +0400
@@ -413,11 +413,11 @@
 			break;

 		} else if (t == 0) {
-			PLOCK(client->lock);
 			if (client->sock->ssl) {
 				if (client->cb_error(client->rx, t, (void *)client))
 					client->client_state |= CLIENT_ERR;
 			}
+			PLOCK(client->lock);
 			if (client->sock->ssl || client->rx) // EOF on stdin is not an error
 				client->client_state |= CLIENT_EOF;
 			PUNLOCK(client->lock);