pubsubd: debug test program
parent
4065b1ab0a
commit
0d50185b3a
|
@ -17,7 +17,7 @@ void usage (char **argv)
|
||||||
|
|
||||||
void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, int version, char *cmd, char *chan)
|
void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, int version, char *cmd, char *chan)
|
||||||
{
|
{
|
||||||
printf ("Simulate connnection : pid %d index %d version %d "
|
printf ("Simulate connection : pid %d index %d version %d "
|
||||||
"cmd %s chan %s\n"
|
"cmd %s chan %s\n"
|
||||||
, pid, index, version, cmd, chan );
|
, pid, index, version, cmd, chan );
|
||||||
|
|
||||||
|
@ -29,9 +29,11 @@ void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, in
|
||||||
struct process p;
|
struct process p;
|
||||||
memset (&p, 0, sizeof (struct process));
|
memset (&p, 0, sizeof (struct process));
|
||||||
|
|
||||||
|
printf ("app creation\n");
|
||||||
if (app_create (&p, pid, index, version)) // called by the application
|
if (app_create (&p, pid, index, version)) // called by the application
|
||||||
ohshit (1, "app_create");
|
ohshit (1, "app_create");
|
||||||
|
|
||||||
|
printf ("connection\n");
|
||||||
// send a message to warn the service we want to do something
|
// send a message to warn the service we want to do something
|
||||||
// line : pid index version action chan
|
// line : pid index version action chan
|
||||||
pubsub_connection (&srv, &p, PUBSUB_PUB, chan);
|
pubsub_connection (&srv, &p, PUBSUB_PUB, chan);
|
||||||
|
@ -42,19 +44,25 @@ void sim_connection (int argc, char **argv, char **env, pid_t pid, int index, in
|
||||||
// first message, "coucou"
|
// first message, "coucou"
|
||||||
m.type = PUBSUB_TYPE_INFO;
|
m.type = PUBSUB_TYPE_INFO;
|
||||||
m.chan = malloc (strlen (chan) + 1);
|
m.chan = malloc (strlen (chan) + 1);
|
||||||
|
memset (m.chan, 0, strlen (chan) + 1);
|
||||||
m.chan[strlen (chan)] = '\0';
|
m.chan[strlen (chan)] = '\0';
|
||||||
m.chanlen = strlen (chan);
|
m.chanlen = strlen (chan);
|
||||||
m.data = malloc (strlen (MYMESSAGE) + 1);
|
m.data = malloc (strlen (MYMESSAGE) + 1);
|
||||||
|
memset (m.data, 0, strlen (MYMESSAGE) + 1);
|
||||||
|
strncpy ((char *) m.data, MYMESSAGE, strlen (MYMESSAGE) + 1);
|
||||||
m.datalen = strlen (MYMESSAGE);
|
m.datalen = strlen (MYMESSAGE);
|
||||||
m.datalen = strlen (MYMESSAGE);
|
|
||||||
|
printf ("send message\n");
|
||||||
pubsub_msg_send (&p, &m);
|
pubsub_msg_send (&p, &m);
|
||||||
|
|
||||||
// free everything
|
// free everything
|
||||||
pubsubd_msg_free (&m);
|
pubsubd_msg_free (&m);
|
||||||
|
|
||||||
|
printf ("disconnection\n");
|
||||||
// disconnect from the server
|
// disconnect from the server
|
||||||
pubsub_disconnect (&p);
|
pubsub_disconnect (&p);
|
||||||
|
|
||||||
|
printf ("destroying app\n");
|
||||||
// the application will shut down, and remove the application named pipes
|
// the application will shut down, and remove the application named pipes
|
||||||
if (app_destroy (&p))
|
if (app_destroy (&p))
|
||||||
ohshit (1, "app_destroy");
|
ohshit (1, "app_destroy");
|
||||||
|
|
Reference in New Issue