Merge branch 'master' of ssh://git.karchnu.fr:2202/Karchnu/perfectos-junk
This commit is contained in:
commit
60d6017ef2
@ -26,8 +26,23 @@ void srv_process_gen (struct process *p
|
||||
|
||||
memset (p->path_in, 0, PATH_MAX);
|
||||
memset (p->path_out, 0, PATH_MAX);
|
||||
|
||||
snprintf(p->path_in , PATH_MAX, "%s%d-%d-in" , TMPDIR, pid, index);
|
||||
snprintf(p->path_out, PATH_MAX, "%s%d-%d-out", TMPDIR, pid, index);
|
||||
//printf("path-in : %s\n", p->path_in );
|
||||
//printf("path-out : %s\n", p->path_out );
|
||||
|
||||
p->in = NULL;
|
||||
p->out = NULL;
|
||||
}
|
||||
|
||||
void srv_process_free (struct process * p)
|
||||
{
|
||||
// TODO nothing to do now
|
||||
|
||||
snprintf(p->path_in , PATH_MAX, "%s/%d-%d-in" , TMPDIR, pid, index);
|
||||
snprintf(p->path_out, PATH_MAX, "%s/%d-%d-out", TMPDIR, pid, index);
|
||||
|
||||
}
|
||||
|
||||
void srv_process_print (struct process *p)
|
||||
|
@ -59,7 +59,6 @@ struct channel * pubsubd_channel_copy (struct channel *c)
|
||||
memcpy (copy, c, sizeof(struct channel));
|
||||
|
||||
if (c->chan != NULL) {
|
||||
printf ("COPY CHAN : %d\n", c->chanlen);
|
||||
copy->chan = malloc (c->chanlen);
|
||||
memset (copy->chan, 0, c->chanlen);
|
||||
memcpy (copy->chan, c->chan, c->chanlen);
|
||||
@ -467,6 +466,7 @@ int pubsubd_get_new_process (const char *spath, struct app_list_elm *ale
|
||||
pubsubd_channel_new (*c, chan);
|
||||
|
||||
struct channel *new_chan = NULL;
|
||||
|
||||
new_chan = pubsubd_channel_get (chans, *c);
|
||||
if (new_chan == NULL) {
|
||||
new_chan = pubsubd_channels_add (chans, *c);
|
||||
|
BIN
pingpong/pingpong
Executable file
BIN
pingpong/pingpong
Executable file
Binary file not shown.
@ -18,38 +18,40 @@ void main_loop (const struct service *srv)
|
||||
int cnt = 10;
|
||||
|
||||
while (cnt--) {
|
||||
|
||||
// -1 : error, 0 = no new process, 1 = new process
|
||||
ret = srv_get_new_process (srv, &proc);
|
||||
//printf("ret = %d\n", ret);
|
||||
|
||||
if (ret == -1) {
|
||||
fprintf (stderr, "error service_get_new_process\n");
|
||||
fprintf (stderr, "MAIN_LOOP: error service_get_new_process\n");
|
||||
continue;
|
||||
} else if (ret == 0) { // that should not happen
|
||||
continue;
|
||||
}
|
||||
|
||||
// printf ("before print\n");
|
||||
srv_process_print (&proc);
|
||||
// printf ("after print\n");
|
||||
//printf ("after print\n");
|
||||
|
||||
// about the message
|
||||
size_t msize = BUFSIZ;
|
||||
char *buf = NULL;
|
||||
|
||||
// printf ("before read\n");
|
||||
if ((ret = srv_read (&proc, &buf, &msize))) {
|
||||
fprintf(stdout, "error service_read %d\n", ret);
|
||||
if ((ret = srv_read (&proc, &buf, &msize)) == -1) {
|
||||
fprintf(stdout, "MAIN_LOOP: error service_read %d\n", ret);
|
||||
continue;
|
||||
}
|
||||
// printf ("after read\n");
|
||||
printf ("read, size %ld : %s\n", msize, buf);
|
||||
|
||||
// printf ("before proc write\n");
|
||||
if ((ret = srv_write (&proc, buf, msize))) {
|
||||
fprintf(stdout, "error service_write %d\n", ret);
|
||||
if ((ret = srv_write (&proc, buf, msize)) == -1) {
|
||||
fprintf(stdout, "MAIN_LOOP: error service_write %d\n", ret);
|
||||
continue;
|
||||
}
|
||||
// printf ("after proc write\n");
|
||||
printf ("\033[32mStill \033[31m%d\033[32m applications to serve\n",cnt);
|
||||
printf ("%d applications to serve\n",cnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,15 +22,18 @@ fi
|
||||
|
||||
for pid in `seq 1 ${NB}`
|
||||
do
|
||||
echo "${pid}"
|
||||
|
||||
# we make the application pipes
|
||||
mkfifo ${REP}/${pid}-1-in 2>/dev/null
|
||||
mkfifo ${REP}/${pid}-1-out 2>/dev/null
|
||||
mkfifo ${REP}${pid}-1-in 2>/dev/null
|
||||
mkfifo ${REP}${pid}-1-out 2>/dev/null
|
||||
|
||||
# pid index version
|
||||
echo "${pid} 1 1" > ${REP}/${SERVICE}
|
||||
echo "${pid} 1 5" > ${REP}${SERVICE}
|
||||
|
||||
# the purpose is to send something in the pipe
|
||||
cat /dev/urandom | base64 | head -n 1 > ${REP}/${pid}-1-out
|
||||
cat /dev/urandom | base64 | head -n 1 > ${REP}${pid}-1-out
|
||||
# echo "hello world" > ${REP}${pid}-1-out
|
||||
|
||||
# the the service will answer with our message
|
||||
cat ${REP}/${pid}-1-in
|
||||
|
Reference in New Issue
Block a user