forked from enlightenment/efl
cserve2: prevent infinite loop during connection
In case of EACCESS, there is no point trying forever In case of EINTR (interrupt), we can consider for now that any signal will prevent the use of cserve2. If we don't do that, Ctrl+C simply won't work :)
This commit is contained in:
parent
6adb604dae
commit
1821c91d10
|
@ -107,10 +107,22 @@ _server_connect(void)
|
|||
len = strlen(remote.sun_path) + sizeof(remote.sun_family);
|
||||
for (;;)
|
||||
{
|
||||
errno = 0;
|
||||
if (connect(s, (struct sockaddr *)&remote, len) != -1) break;
|
||||
if (errno == EACCES)
|
||||
{
|
||||
ERR("not authorized to connect to cserve2!");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
ERR("cserve2 connect failed: [%d] %s. Retrying...", errno, strerror(errno));
|
||||
|
||||
usleep(1000);
|
||||
errno = 0;
|
||||
usleep(10000);
|
||||
if (errno == EINTR)
|
||||
{
|
||||
WRN("received interruption while trying to connect to cserve2!");
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
/* FIXME: Here we should identify the error, maybe signal the daemon manager
|
||||
* that we need cserve2 to [re]start or just quit and return false.
|
||||
|
|
Loading…
Reference in New Issue