From b947acff653562c5be7d21128555a16f87924d18 Mon Sep 17 00:00:00 2001 From: hackbard Date: Mon, 8 Nov 2004 23:30:07 +0000 Subject: [PATCH] network problems partially fixed --- nlsop_client.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/nlsop_client.c b/nlsop_client.c index ce42433..3f76549 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -66,6 +66,7 @@ int *gi; unsigned char dc; int get_data_and_calc(t_event *event,void *allineed); +int nop(t_event *event,void *allineed); int usage(char *prog) { @@ -304,19 +305,28 @@ u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { void send_data(int signum) { int c; + unsigned char data; c=gd3_l->max_x*gd3_l->max_y*gd3_l->max_z; + printf("%d <-\n",c); + network_send(gnet->connection[0].fd,&dc,1); /* network_send(gnet->connection[0].fd,(unsigned char *)gd3_l, sizeof(d3_lattice)); network_send(gnet->connection[0].fd,(unsigned char *)gmy_info,sizeof(info)); */ + printf("debug: sent dc\n"); network_send(gnet->connection[0].fd,gd3_l->status,c*sizeof(unsigned char)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent ac\n"); network_send(gnet->connection[0].fd,(unsigned char *)gd3_l->extra, c*sizeof(int)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); + printf("debug: sent cc\n"); network_send(gnet->connection[0].fd,(unsigned char *)gi,sizeof(int)); + network_receive(gnet->connection[0].fd,&data,sizeof(unsigned char)); } @@ -397,7 +407,12 @@ int main(int argc,char **argv) /* wait for job */ event_math(net.connection[0].fd,&event,READ,ADD); printf("idle, waiting for jobs ...\n"); - event_start(&event,NULL,get_data_and_calc,NULL); + event_start(&event,NULL,get_data_and_calc,nop); + + return 1; +} + +int nop(t_event *event,void *allineed) { return 1; } @@ -413,7 +428,7 @@ int get_data_and_calc(t_event *event,void *allineed) { u32 x_c,y_c,z_c; int i,j; int c_step; - unsigned char data[256]; + unsigned char data; t_net *net; @@ -430,8 +445,8 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("got a new job ...\n"); /* get info (+data) */ - network_receive(net->connection[0].fd,data,1); - if(data[0]==NLSOP_NJOB || data[0]==NLSOP_CJOB) { + network_receive(net->connection[0].fd,&data,sizeof(unsigned char)); + if(data==NLSOP_NJOB || data==NLSOP_CJOB) { network_receive(net->connection[0].fd,(unsigned char *)&d3_l, sizeof(d3_lattice)); network_receive(net->connection[0].fd,(unsigned char *)&my_info, @@ -448,15 +463,23 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("extra malloc failed\n"); return -1; } - if(data[0]==NLSOP_CJOB) { + if(data==NLSOP_CJOB) { + data=DATA_OK; network_receive(net->connection[0].fd,d3_l.status, j*sizeof(unsigned char)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); network_receive(net->connection[0].fd,(unsigned char *)d3_l.extra, j*sizeof(int)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); network_receive(net->connection[0].fd,(unsigned char *)&c_step, sizeof(int)); + network_send(net->connection[0].fd,&data,sizeof(unsigned char)); } } + else { + printf("unknown instruction, restarting ...\n"); + return -1; + } printf("starting simulation with following parameters:\n"); printf("b = %f | c = %f | s = %f\n",my_info.b,my_info.c,my_info.s); @@ -533,6 +556,8 @@ int get_data_and_calc(t_event *event,void *allineed) { dc=DC_QUIT; /* shutdown/free/close everything now ... */ + free(d3_l.status); + free(d3_l.extra); return 1; } -- 2.20.1