[dovecot-cvs] dovecot/src/dict dict-server.c,1.3,1.4
cras at dovecot.org
cras at dovecot.org
Sat Dec 31 00:19:57 EET 2005
Update of /var/lib/cvs/dovecot/src/dict
In directory talvi:/tmp/cvs-serv729
Modified Files:
dict-server.c
Log Message:
unlink stale socket
Index: dict-server.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/dict-server.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dict-server.c 30 Dec 2005 22:18:44 -0000 1.3
+++ dict-server.c 30 Dec 2005 22:19:55 -0000 1.4
@@ -407,12 +407,28 @@
struct dict_server *dict_server_init(const char *path)
{
struct dict_server *server;
+ int i;
server = i_new(struct dict_server, 1);
server->path = i_strdup(path);
- server->fd = net_listen_unix(path, 64);
- if (server->fd == -1)
- i_fatal("net_listen_unix(%s) failed: %m", path);
+
+ for (i = 0; i < 2; i++) {
+ server->fd = net_listen_unix(path, 64);
+ if (server->fd != -1)
+ break;
+
+ if (errno != EADDRINUSE)
+ 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);
+ }
+
server->io = io_add(server->fd, IO_READ,
dict_server_listener_accept, server);
server->cache = dict_cache_init();
More information about the dovecot-cvs
mailing list