view Paper/src/LocalDGMQueue.cbc @ 42:01b88c0dd337

tweak
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Mon, 28 Feb 2022 22:11:26 +0900
parents a3cda2aa18aa
children
line wrap: on
line source

__code getDataLocalDGMQueue(struct LocalDGMQueue* cQueue, __code next(...), __code whenEOF(...), __code whenError(...)){
    int recv_size, send_size;
    char send_buf;

    union Data* recv_data;
    recv_size = read(tQueue->socket, recv_data, sizeof(union Data));
    if (recv_size == -1) {
        printf("recv error\n");
        goto whenError(...);
    }
    if (recv_size == 0) {
        printf("connection ended\n");
        goto whenError(...);
    }


    FileString* fileString = NEW(FileString);
    fileString = recv_data;
    if (fileString->EoF) == 1) {
        send_buf = 0;
        send_size = send(cQueue->socket, &send_buf, 1, 0);
        if (send_size == -1) {
            printf("send error\n");
        }
        close(cQueue->buffer);
        goto whenEOF(...);
    } else {
        send_buf = 1;
        send_size = send(cQueue->socket, &send_buf, 1, 0);
        if (send_size == -1) {
            printf("send error\n");
            goto whenError(...);
        }
    }

    Gearef(context, cQueue)->data = recv_data;
    goto putLocalDGMQueue(recv_data, next);
}