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);
if (errno != EAGAIN)
{
ERR("%d: %s", errno, strerror(errno));
- ecore_main_fd_handler_del(conn->fdh);
- conn->fdh = NULL;
+ pulse_disconnect(conn);
}
}
else
if (errno != EAGAIN)
{
ERR("%d: %s", errno, strerror(errno));
- ecore_main_fd_handler_del(conn->fdh);
- conn->fdh = NULL;
+ pulse_disconnect(conn);
}
}
else
if (errno != EAGAIN)
{
ERR("%d: %s", errno, strerror(errno));
- ecore_main_fd_handler_del(conn->fdh);
- conn->fdh = NULL;
+ pulse_disconnect(conn);
}
}
else
if (errno != EAGAIN)
{
ERR("%d: %s", errno, strerror(errno));
- ecore_main_fd_handler_del(conn->fdh);
- conn->fdh = NULL;
+ pulse_disconnect(conn);
}
}
else
if (errno != EAGAIN)
{
ERR("%d: %s", errno, strerror(errno));
- ecore_main_fd_handler_del(conn->fdh);
- conn->fdh = NULL;
+ pulse_disconnect(conn);
}
}
else
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);
if (!wprev->auth)
msg_sendmsg_creds(conn, wprev);
+
if (wprev->auth && msg_send(conn, wprev))
{
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);
}
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)
{
if (!ev) return;