📄 daemoncom.c
字号:
/** @file daemoncom.c implements the communication between daemons implied in the fault tolerant protocol */#include "config.h"#include "debug.h"#include "vtypes.h"#include "flitvec.h"#include "daemoncom.h"#include "otherdaemoncomm.h"#include "localmpi.h"void ftp_on_disconnect(SockInfo mpipeer[], int rank){ return;}void ftp_init(int sizeofmpipeer, int rank){ return;}static void dummy_sendcomplete(flit *f, void *p){ free(p);}void ftp_newOutgoingMessage(pkt_header *msg){ flitvec *fv; /** we have 2 flits (but of course, in this case, we may have * only one flit. */ fv = newflitvec(2); /** flit0 : the pkt header */ newflit(&(fv->flittab[0]), msg, sizeof(pkt_header),NULL); /** flit1 : the data */ newflit(&(fv->flittab[1]), ((char*)msg)+sizeof(pkt_header), ntohl(msg->iSize), dummy_sendcomplete); /** we need to send everything, so we let cflitindex and cflitpos * be zero */ /** we set parameter to be the message, in order to free it in * dummy_sendcomplete */ fv->parameter = msg; /** we add this new flitvec to the list of messages to be sent */ addtopeersend(fv); return;}static void dummy_receive(flit *f, void *param){ pkt_header *pkt = (pkt_header *)param; if ( waiting_for_tag( ntohl(pkt->iTag) ) ) { printi ("Recv", "this is the pending message"); clearpendingtag(); on_writeback(pkt); } else pending_add(pkt);}flitvec *ftp_create_newfv( pkt_header *pkt ){ flitvec *res; pkt_header *fv0; char *data; /** we use 2 flits */ res = newflitvec(2); /** first flit is always the pkt_header */ /** pkt must be copied if further use is needed * (it is currently allocated in stack) * Moreover, we allocate the buffer of reception */ fv0 = (pkt_header*)malloc(sizeof(pkt_header) + ntohl(pkt->iSize)); data = ((char*)fv0) + sizeof(pkt_header); memcpy(fv0, pkt, sizeof(pkt_header)); /** it is the first flit */ newflit(&(res->flittab[0]), fv0, sizeof(pkt_header), NULL); /** second flit is the data */ /** we attach the data to the flit */ newflit(&(res->flittab[1]), data, ntohl(pkt->iSize), dummy_receive); /** Since we already have received the first flit, * we don't receive it again ! */ res->cflitindex = 1; res->cflitpos = 0; /** Last : fix the parameter given to dummy_receive, in addition to * the flit */ res->parameter = fv0; return res;}void ftp_on_soliloquize_send(pkt_header *pkt){ return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -