# HG changeset patch # User ichikitakahiro # Date 1642236184 -32400 # Node ID a9c630cc1c6540dceb01e2d31dac0c41b2dcbfcb # Parent 9ca9c36a4633efcecb86311eff786936bd08ad41 tweak diff -r 9ca9c36a4633 -r a9c630cc1c65 src/parallel_execution/examples/socketQueue/FileString.h --- a/src/parallel_execution/examples/socketQueue/FileString.h Sat Jan 15 16:13:59 2022 +0900 +++ b/src/parallel_execution/examples/socketQueue/FileString.h Sat Jan 15 17:43:04 2022 +0900 @@ -1,4 +1,4 @@ typedef struct FileString <> { char str[1024]; - int* size; + int size; } FileString; diff -r 9ca9c36a4633 -r a9c630cc1c65 src/parallel_execution/examples/socketQueue/LocalDGMQueue.cbc --- a/src/parallel_execution/examples/socketQueue/LocalDGMQueue.cbc Sat Jan 15 16:13:59 2022 +0900 +++ b/src/parallel_execution/examples/socketQueue/LocalDGMQueue.cbc Sat Jan 15 17:43:04 2022 +0900 @@ -182,9 +182,10 @@ char recv_buf[BUF_SIZE], send_buf; /* クライアントから文字列を受信 */ - FileString* fileString = NEW(FileString); - recv_size = recv(tQueue->socket, fileString, sizeof(struct FileString), 0); - printf("[%s] [%d]\n", fileString->str, fileString->size); + union Data* recv_data; + recv_size = recv(tQueue->socket, recv_data, sizeof(union Data), 0); + //printf("[%s] [%d]\n", fileString->str, fileString->size); + printf("size is %d\n", sizeof(union Data)); if (recv_size == -1) { printf("recv error\n"); goto exit_code(); @@ -198,8 +199,11 @@ /* 文字列が"finish"ならクライアントとの接続終了 */ + + FileString* fileString = NEW(FileString); + fileString = recv_data; if (strcmp(fileString->str, "finish") == 0) { - /* 接続終了を表す0を送信 */ + /* 接続終了を表す0を送信 */ send_buf = 0; send_size = send(tQueue->socket, &send_buf, 1, 0); if (send_size == -1) { @@ -216,9 +220,11 @@ } } - Gearef(context, TQueue)->data = fileString; + + + Gearef(context, TQueue)->data = recv_data; - goto putLocalDGMQueue(fileString, next); + goto putLocalDGMQueue(recv_data, next); } __code sendData(struct RemoteDGMQueue* tQueue, struct FileString* string, __code next(...)){ diff -r 9ca9c36a4633 -r a9c630cc1c65 src/parallel_execution/examples/socketQueue/RemoteDGMQueue.cbc --- a/src/parallel_execution/examples/socketQueue/RemoteDGMQueue.cbc Sat Jan 15 16:13:59 2022 +0900 +++ b/src/parallel_execution/examples/socketQueue/RemoteDGMQueue.cbc Sat Jan 15 17:43:04 2022 +0900 @@ -161,16 +161,16 @@ goto next(...); } -__code sendData(struct RemoteDGMQueue* tQueue, FileString* string, __code next(...)){ +__code sendData(struct RemoteDGMQueue* tQueue, union Data* data, __code next(...)){ char send_buf[BUF_SIZE], recv_buf; int send_size, recv_size; /* サーバーに送る文字列を取得 */ - memcpy(send_buf, string->str, sizeof(send_buf)); + //memcpy(send_buf, string->str, sizeof(send_buf)); /* 文字列を送信 */ - send_size = send(tQueue->socket, string, sizeof(struct FileString), 0); + send_size = send(tQueue->socket, data, sizeof(union Data), 0); if (send_size == -1) { printf("send error\n"); close(tQueue->socket); @@ -204,11 +204,15 @@ __code sendDataRemoteDGMQueue_stub(struct Context* context) { RemoteDGMQueue* tQueue = (RemoteDGMQueue*)GearImpl(context, TQueue, tQueue); - FileString* string = Gearef(context, TQueue)->data; + union Data* data = Gearef(context, TQueue)->data; enum Code next = Gearef(context, TQueue)->next; - goto sendDataRemoteDGMQueue(context, tQueue, string, next); + goto sendDataRemoteDGMQueue(context, tQueue, data, next); } __code getData(struct RemoteDGMQueue* tQueue, __code next(...), __code whenEOF(...)){ } + +__code closeSocket(struct RemoteDGMQueue* tQueue, __code next(...)){ + +} \ No newline at end of file diff -r 9ca9c36a4633 -r a9c630cc1c65 src/parallel_execution/examples/socketQueue/TQueue.h --- a/src/parallel_execution/examples/socketQueue/TQueue.h Sat Jan 15 16:13:59 2022 +0900 +++ b/src/parallel_execution/examples/socketQueue/TQueue.h Sat Jan 15 17:43:04 2022 +0900 @@ -10,7 +10,7 @@ __code take(Impl* tQueue, __code next(union Data* data, ...)); __code isEmpty(Impl* tQueue, __code next(...), __code whenEmpty(...)); - __code sendData(Impl* tQueue, FileString* string, __code next(...)); + __code sendData(Impl* tQueue, union Data* data, __code next(...)); __code getData(Impl* tQueue, __code next(...), __code whenEOF(...)); __code next(...); } TQueue;