Re: [Dovecot] Bug in dovecot 1.2 dict

2008-10-05 Thread Robert Schetterer
Robert Schetterer schrieb:
> Timo Sirainen schrieb:
>> On Thu, 2008-10-02 at 20:30 +0200, Bernhard Herzog wrote:
>>> On 02.10.2008, Sascha Wilde wrote:
 We discovered that this new code in dict-server.c seems to be the problem:

   server->fd = net_listen_unix_unlink_stale(path, 64);
   if (server->fd == -1) {
   if (errno == EADDRINUSE)
   i_fatal("Socket already exists: %s", path);
   else
   i_fatal("net_listen_unix(%s) failed: %m", path);
   }
>>> It turns out the problem is that net_listen_unix_unlink_stale is called 
>>> even 
>>> if a file descriptor is passed into dict_server_init.  The attached patch 
>>> fixes it for me.
>> Thanks. I fixed it slightly differently to avoid annoying indentation :)
>> http://hg.dovecot.org/dovecot-1.2/rev/3718d603f9d0
>>
> 
> Hi @ll
> thx so i was right dict was broken in 1.2
> 

as far my few tests results
mysql quota dict works now too in 1.2

-- 
Best Regards

MfG Robert Schetterer

Germany/Munich/Bavaria


Re: [Dovecot] Bug in dovecot 1.2 dict

2008-10-05 Thread Robert Schetterer
Timo Sirainen schrieb:
> On Thu, 2008-10-02 at 20:30 +0200, Bernhard Herzog wrote:
>> On 02.10.2008, Sascha Wilde wrote:
>>> We discovered that this new code in dict-server.c seems to be the problem:
>>>
>>>   server->fd = net_listen_unix_unlink_stale(path, 64);
>>>   if (server->fd == -1) {
>>>   if (errno == EADDRINUSE)
>>>   i_fatal("Socket already exists: %s", path);
>>>   else
>>>   i_fatal("net_listen_unix(%s) failed: %m", path);
>>>   }
>> It turns out the problem is that net_listen_unix_unlink_stale is called even 
>> if a file descriptor is passed into dict_server_init.  The attached patch 
>> fixes it for me.
> 
> Thanks. I fixed it slightly differently to avoid annoying indentation :)
> http://hg.dovecot.org/dovecot-1.2/rev/3718d603f9d0
> 

Hi @ll
thx so i was right dict was broken in 1.2

-- 
Best Regards

MfG Robert Schetterer

Germany/Munich/Bavaria


Re: [Dovecot] Bug in dovecot 1.2 dict

2008-10-05 Thread Timo Sirainen
On Thu, 2008-10-02 at 20:30 +0200, Bernhard Herzog wrote:
> On 02.10.2008, Sascha Wilde wrote:
> > We discovered that this new code in dict-server.c seems to be the problem:
> >
> >   server->fd = net_listen_unix_unlink_stale(path, 64);
> >   if (server->fd == -1) {
> >   if (errno == EADDRINUSE)
> >   i_fatal("Socket already exists: %s", path);
> >   else
> >   i_fatal("net_listen_unix(%s) failed: %m", path);
> >   }
> 
> It turns out the problem is that net_listen_unix_unlink_stale is called even 
> if a file descriptor is passed into dict_server_init.  The attached patch 
> fixes it for me.

Thanks. I fixed it slightly differently to avoid annoying indentation :)
http://hg.dovecot.org/dovecot-1.2/rev/3718d603f9d0



signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] Bug in dovecot 1.2 dict

2008-10-02 Thread Bernhard Herzog
On 02.10.2008, Sascha Wilde wrote:
> We discovered that this new code in dict-server.c seems to be the problem:
>
>   server->fd = net_listen_unix_unlink_stale(path, 64);
>   if (server->fd == -1) {
>   if (errno == EADDRINUSE)
>   i_fatal("Socket already exists: %s", path);
>   else
>   i_fatal("net_listen_unix(%s) failed: %m", path);
>   }

It turns out the problem is that net_listen_unix_unlink_stale is called even 
if a file descriptor is passed into dict_server_init.  The attached patch 
fixes it for me.

Regards,

   Bernhard

-- 
Bernhard Herzog  |  ++49-541-335 08 30  |  http://www.intevation.de/
Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
diff -r 1155c1f7fed8 src/dict/dict-server.c
--- a/src/dict/dict-server.c	Wed Oct 01 16:07:57 2008 +0300
+++ b/src/dict/dict-server.c	Thu Oct 02 20:07:57 2008 +0200
@@ -526,12 +526,14 @@ struct dict_server *dict_server_init(con
 	server->path = i_strdup(path);
 	server->fd = fd;
 
-	server->fd = net_listen_unix_unlink_stale(path, 64);
 	if (server->fd == -1) {
-		if (errno == EADDRINUSE)
-			i_fatal("Socket already exists: %s", path);
-		else
-			i_fatal("net_listen_unix(%s) failed: %m", path);
+		server->fd = net_listen_unix_unlink_stale(path, 64);
+		if (server->fd == -1) {
+			if (errno == EADDRINUSE)
+i_fatal("Socket already exists: %s", path);
+			else
+i_fatal("net_listen_unix(%s) failed: %m", path);
+		}
 	}
 
 	server->io = io_add(server->fd, IO_READ,


signature.asc
Description: This is a digitally signed message part.


[Dovecot] Bug in dovecot 1.2 dict

2008-10-02 Thread Sascha Wilde
Hi Timo,
Hi *,

in 1.2 the dict server (tested with sqlite backend) is somewhat broken.
It bails out regularly with "Fatal: dict: Socket already exists: ..."
(looks like a race condition as it doesn't fail always).

We discovered that this new code in dict-server.c seems to be the problem:

server->fd = net_listen_unix_unlink_stale(path, 64);
if (server->fd == -1) {
if (errno == EADDRINUSE)
i_fatal("Socket already exists: %s", path);
else
i_fatal("net_listen_unix(%s) failed: %m", path);
}

replacing it with the old code:

int i = 0;
  [...]
while (server->fd == -1) {
server->fd = net_listen_unix(path, 64);
if (server->fd != -1)
break;

if (errno != EADDRINUSE || ++i == 2)
i_fatal("net_listen_unix(%s) failed: %m", path);

/* see if it really exists */
if (net_connect_unix(path) != -1 || errno != ECONNREFUSED)
i_fatal("Socket already exists: %s", path);

/* delete and try again */
if (unlink(path) < 0)
i_fatal("unlink(%s) failed: %m", path);
}

"fixes" the problem.  But I think the real fix would have to be done in
the new function `net_listen_unix_unlink_stale'.

cheers
sascha
-- 
Sascha Wilde  OpenPGP key: 4BB86568
Intevation GmbH, Osnabrück http://www.intevation.de/~wilde/
Amtsgericht Osnabrück, HR B 18998 http://www.intevation.de/
Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner


pgpAC1O2gXijB.pgp
Description: PGP signature