plus de fuite de mémoire, manque plus qu'à lire et push les messages
This commit is contained in:
parent
e9c9e551fa
commit
723828c4b8
@ -279,19 +279,13 @@ int pubsubd_get_new_process (struct service *srv, struct app_list_elm *ale
|
|||||||
if (srv == NULL || ale == NULL || chans == NULL)
|
if (srv == NULL || ale == NULL || chans == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (ale->p != NULL) {
|
|
||||||
free (ale->p);
|
|
||||||
ale->p = NULL;
|
|
||||||
}
|
|
||||||
ale->p = malloc (sizeof (struct process));
|
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t msize;
|
size_t msize;
|
||||||
srv_get_listen_raw (srv, &buf, &msize);
|
srv_get_listen_raw (srv, &buf, &msize);
|
||||||
|
|
||||||
// parse pubsubd init msg (sent in TMPDIR/<service>)
|
// parse pubsubd init msg (sent in TMPDIR/<service>)
|
||||||
//
|
//
|
||||||
// line fmt : pid index version chan action
|
// line fmt : pid index version action chan
|
||||||
// action : quit | pub | sub
|
// action : quit | pub | sub
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -314,11 +308,6 @@ int pubsubd_get_new_process (struct service *srv, struct app_list_elm *ale
|
|||||||
case 2 : index = strtoul(token, NULL, 10); break;
|
case 2 : index = strtoul(token, NULL, 10); break;
|
||||||
case 3 : version = strtoul(token, NULL, 10); break;
|
case 3 : version = strtoul(token, NULL, 10); break;
|
||||||
case 4 : {
|
case 4 : {
|
||||||
memcpy (chan, token, (strlen (token) < BUFSIZ) ?
|
|
||||||
strlen (token) : BUFSIZ);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 5 : {
|
|
||||||
if (strncmp("both", token, 4) == 0) {
|
if (strncmp("both", token, 4) == 0) {
|
||||||
ale->action = PUBSUB_BOTH;
|
ale->action = PUBSUB_BOTH;
|
||||||
}
|
}
|
||||||
@ -331,6 +320,13 @@ int pubsubd_get_new_process (struct service *srv, struct app_list_elm *ale
|
|||||||
else { // everything else is about killing the service
|
else { // everything else is about killing the service
|
||||||
ale->action = PUBSUB_QUIT;
|
ale->action = PUBSUB_QUIT;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5 : {
|
||||||
|
if (ale->action != PUBSUB_QUIT)
|
||||||
|
memcpy (chan, token, (strlen (token) < BUFSIZ) ?
|
||||||
|
strlen (token) : BUFSIZ);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,7 +351,15 @@ int pubsubd_get_new_process (struct service *srv, struct app_list_elm *ale
|
|||||||
}
|
}
|
||||||
pubsubd_channel_free (&c);
|
pubsubd_channel_free (&c);
|
||||||
|
|
||||||
srv_process_gen (ale->p, pid, index, version);
|
if (ale->p != NULL) {
|
||||||
|
free (ale->p);
|
||||||
|
ale->p = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ale->action != PUBSUB_QUIT) {
|
||||||
|
ale->p = malloc (sizeof (struct process));
|
||||||
|
srv_process_gen (ale->p, pid, index, version);
|
||||||
|
}
|
||||||
|
|
||||||
// add the subscriber
|
// add the subscriber
|
||||||
if (ale->action == PUBSUB_SUB || ale->action == PUBSUB_BOTH)
|
if (ale->action == PUBSUB_SUB || ale->action == PUBSUB_BOTH)
|
||||||
|
@ -26,6 +26,10 @@ void pubsubd_msg_serialize (const struct pubsub_msg *msg, char **data, size_t *l
|
|||||||
void pubsubd_msg_unserialize (struct pubsub_msg *msg, const char *data, size_t len);
|
void pubsubd_msg_unserialize (struct pubsub_msg *msg, const char *data, size_t len);
|
||||||
void pubsubd_msg_free (struct pubsub_msg *msg);
|
void pubsubd_msg_free (struct pubsub_msg *msg);
|
||||||
|
|
||||||
|
// parse pubsubd init msg (sent in TMPDIR/<service>)
|
||||||
|
//
|
||||||
|
// line fmt : pid index version action chan
|
||||||
|
// action : quit | pub | sub
|
||||||
int pubsubd_get_new_process (struct service *srv, struct app_list_elm *ale
|
int pubsubd_get_new_process (struct service *srv, struct app_list_elm *ale
|
||||||
, struct channels *chans);
|
, struct channels *chans);
|
||||||
int pubsubd_msg_read_cb (FILE *f, char ** buf, size_t * msize);
|
int pubsubd_msg_read_cb (FILE *f, char ** buf, size_t * msize);
|
||||||
@ -68,7 +72,7 @@ void pubsubd_channels_del_all (struct channels *chans);
|
|||||||
// head of the list
|
// head of the list
|
||||||
LIST_HEAD(app_list_head, app_list_elm);
|
LIST_HEAD(app_list_head, app_list_elm);
|
||||||
|
|
||||||
enum app_list_elm_action { PUBSUB_QUIT, PUBSUB_PUB, PUBSUB_SUB, PUBSUB_BOTH };
|
enum app_list_elm_action {PUBSUB_QUIT = 1, PUBSUB_PUB, PUBSUB_SUB, PUBSUB_BOTH};
|
||||||
|
|
||||||
// element of the list
|
// element of the list
|
||||||
struct app_list_elm {
|
struct app_list_elm {
|
||||||
|
@ -37,6 +37,7 @@ main(int argc, char* argv[])
|
|||||||
printf ("Quitting ...\n");
|
printf ("Quitting ...\n");
|
||||||
|
|
||||||
pubsubd_channels_del_all (&chans);
|
pubsubd_channels_del_all (&chans);
|
||||||
|
// pubsubd_app_list_elm_free (&ale);
|
||||||
srv_close (&srv);
|
srv_close (&srv);
|
||||||
|
|
||||||
// TODO end the threads
|
// TODO end the threads
|
||||||
|
Reference in New Issue
Block a user