forked from enlightenment/enlightenment
add pulse_disconnect() function and properly send disconnect events when disconnecting during pulse auth
SVN revision: 77505
This commit is contained in:
parent
0d3c51e8bc
commit
d40acc5046
|
@ -37,6 +37,7 @@ void pulse_shutdown(void);
|
|||
|
||||
Pulse *pulse_new(void);
|
||||
Eina_Bool pulse_connect(Pulse *conn);
|
||||
void pulse_disconnect(Pulse *conn);
|
||||
void pulse_free(Pulse *conn);
|
||||
void pulse_cb_set(Pulse *conn, uint32_t tagnum, Pulse_Cb cb);
|
||||
void pulse_server_info_free(Pulse_Server_Info *ev);
|
||||
|
|
|
@ -33,8 +33,7 @@ msg_recv_creds(Pulse *conn, Pulse_Tag *tag)
|
|||
if (errno != EAGAIN)
|
||||
{
|
||||
ERR("%d: %s", errno, strerror(errno));
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
pulse_disconnect(conn);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -84,8 +83,7 @@ msg_recv(Pulse *conn, Pulse_Tag *tag)
|
|||
if (errno != EAGAIN)
|
||||
{
|
||||
ERR("%d: %s", errno, strerror(errno));
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
pulse_disconnect(conn);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -138,8 +136,7 @@ msg_sendmsg_creds(Pulse *conn, Pulse_Tag *tag)
|
|||
if (errno != EAGAIN)
|
||||
{
|
||||
ERR("%d: %s", errno, strerror(errno));
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
pulse_disconnect(conn);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -165,8 +162,7 @@ msg_send_creds(Pulse *conn, Pulse_Tag *tag)
|
|||
if (errno != EAGAIN)
|
||||
{
|
||||
ERR("%d: %s", errno, strerror(errno));
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
pulse_disconnect(conn);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -198,8 +194,7 @@ msg_send(Pulse *conn, Pulse_Tag *tag)
|
|||
if (errno != EAGAIN)
|
||||
{
|
||||
ERR("%d: %s", errno, strerror(errno));
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
pulse_disconnect(conn);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -196,11 +196,7 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh)
|
|||
if (!tag->dsize)
|
||||
{
|
||||
ERR("Kicked!");
|
||||
conn->state = PA_STATE_INIT;
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
close(conn->fd);
|
||||
ecore_event_add(PULSE_EVENT_DISCONNECTED, conn, pulse_fake_free, NULL);
|
||||
pulse_disconnect(conn);
|
||||
return NULL;
|
||||
}
|
||||
tag->data = malloc(tag->dsize);
|
||||
|
@ -274,6 +270,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
|
|||
|
||||
if (!wprev->auth)
|
||||
msg_sendmsg_creds(conn, wprev);
|
||||
|
||||
|
||||
if (wprev->auth && msg_send(conn, wprev))
|
||||
{
|
||||
|
@ -354,10 +351,7 @@ con(Pulse *conn, int type __UNUSED__, Ecore_Con_Event_Server_Add *ev)
|
|||
fd = ecore_con_server_fd_get(ev->server);
|
||||
if (fd == -1)
|
||||
{
|
||||
conn->state = PA_STATE_INIT;
|
||||
ecore_con_server_del(ev->server);
|
||||
conn->svr = NULL;
|
||||
ecore_event_add(PULSE_EVENT_DISCONNECTED, conn, pulse_fake_free, NULL);
|
||||
pulse_disconnect(conn);
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
conn->fd = dup(fd);
|
||||
|
@ -752,6 +746,27 @@ pulse_connect(Pulse *conn)
|
|||
return !!conn->svr;
|
||||
}
|
||||
|
||||
void
|
||||
pulse_disconnect(Pulse *conn)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(conn);
|
||||
if (conn->state == PA_STATE_INIT) return;
|
||||
conn->state = PA_STATE_INIT;
|
||||
if (conn->fdh)
|
||||
{
|
||||
ecore_main_fd_handler_del(conn->fdh);
|
||||
conn->fdh = NULL;
|
||||
close(conn->fd);
|
||||
conn->fd = -1;
|
||||
}
|
||||
else if (conn->svr)
|
||||
{
|
||||
ecore_con_server_del(conn->svr);
|
||||
conn->svr = NULL;
|
||||
}
|
||||
ecore_event_add(PULSE_EVENT_DISCONNECTED, conn, pulse_fake_free, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
pulse_server_info_free(Pulse_Server_Info *ev)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue