void reset_event() { switch ( restart_cause() ) { case WDT_TIMEOUT: { printf("@WDT\r\n"); sprintf(event_str, ",restart cause,WD time-out\r\n"); record_event(); recovery(); break; } case WDT_FROM_SLEEP: { printf("@WDS\r\n"); sprintf(event_str, ",restart cause,WD from sleep\r\n"); record_event(); recovery(); break; } case NORMAL_POWER_UP: { printf("@NPU\r\n"); sprintf(event_str, ",id#[%Lu],power applied,SD initialized\r\n", nv_serial); record_event(); break; } case RESET_INSTRUCTION: { printf("@RST\r\n"); sprintf(event_str, ",restart cause,reset instruction\r\n"); record_event(); break; } case BROWNOUT_RESTART: { printf("@BOR\r\n"); sprintf(event_str, ",restart cause,brown-out\r\n"); record_event(); recovery(); break; } case MCLR_FROM_SLEEP: { printf("@MRS\r\n"); sprintf(event_str, ",restart cause,MCLR from sleep\r\n"); record_event(); recovery(); break; } case MCLR_FROM_RUN: { printf("@MRR\r\n"); sprintf(event_str, ",restart cause,MCLR when running\r\n"); record_event(); recovery(); break; } } }
//写语句 //<写语句>::=write'('<字符串>,<表达式>')'|write'('<字符串>')'|write'('<表达式>')' AST_node stat_write(AST_node t) { printf("----------------Write Statement--------------\n"); t->ast_type = WRITESTAT; match(WRITE,t); if (!match(LPARENT,t)) { error("Missing left parenthesis"); recovery(6, STRING, MINUS, PLUS, IDENT, LPARENT, NUM); } if (match(STRING,t)) { if (match(COMMA,t)) { express(t); } } else { express(t); } if (!match(RPARENT,t)) { error("Missing right parenthesis"); recovery(9, SEMICOLON, END, IDENT, IF, DO, BEGIN, READ, WRITE, FOR); } printf("----------------End of Write--------------\n"); return t; }
//读语句 //<读语句>::=read'('<标识符>{,<标识符>}')' AST_node stat_read(AST_node t) { printf("----------------Read Statement--------------\n"); t->ast_type = READSTAT; match(READ,t); if (!match(LPARENT,t)) { error("Missing left parenthesis"); recovery(1, IDENT); } if (!match(IDENT,t)) { error("Wrong args"); recovery(10, COMMA, RPARENT, IDENT, IF, DO, BEGIN, READ, WRITE, FOR, END); } while (match(COMMA,t)) { if (!match(IDENT,t)) { error("Wrong args"); recovery(2, COMMA, RPARENT); } } if (!match(RPARENT,t)) { error("Missing right parenthesis"); recovery(2, END, SEMICOLON); } printf("----------------End of Read--------------\n"); return t; }
int recv_wrapper(int sock, int send_sock, char buf[], int size) { int numBytes=0; int numBytesAll = 0; if (flag==1) { fprintf(stdout,"main:waiting to received %d bytes...\n", size); } while (numBytesAll < size) { numBytes = recv(sock, buf, size, MSG_WAITALL); if (numBytes<0) { fprintf(stdout,"main: Receive clientID error after %d bytes received, when it was expecting %d...\n", numBytesAll, size); fprintf(stdout,"main: error description: %d\n", errno); recovery(sock, send_sock); //goto recover; } else if (numBytes==0) { fprintf(stdout,"main: Receive clientID error after %d bytes received, when it was expecting %d...\n", numBytesAll, size); fprintf(stdout,"main: error description: EOF\n"); recovery(sock, send_sock); //goto recover; } else { if (flag == 1) fprintf(stdout,"main: Received %d bytes...\n", numBytes); } numBytesAll += numBytes; if (numBytesAll == 3) { if (strncasecmp(buf, "end", 3)==0) { fprintf(stdout, "main: receive end notice, exit\n"); recovery(sock, send_sock); //goto recover; } } } if (flag==1) { fprintf(stdout,"main:just received %d bytes...\n", numBytesAll); fprintf(stdout,"main: recv_wrapper: %s\n", buf); } fflush(stdout); }
/************************************************************* * * exceptionHandler - Wait for Messages that indicate some problem * with the system. Then perform appropriate recovery. * * Author Greg Brissey 12-7-94 */ pHandler(MSG_Q_ID msges) { Cntlr_Comm msge; int *val; int bytes; void recovery(Cntlr_Comm *); void extrecovery(Cntlr_Comm *); DPRINT(1,"pHandler :Server LOOP Ready & Waiting.\n"); FOREVER { markReady(PHANDLER_FLAGBIT); memset( &msge, 0, sizeof( Cntlr_Comm ) ); bytes = msgQReceive(pMsgesToPHandlr, (char*) &msge, sizeof( Cntlr_Comm ), WAIT_FOREVER); markBusy(PHANDLER_FLAGBIT); DPRINT5(-1,"'%s': pHandler: recv: %d bytes, From Cntlr: '%s', Exception Type: %d, Event: %d \n", hostName,bytes, msge.cntlrId, msge.cmd, msge.arg1); if (strcmp(msge.cntlrId,hostName) == 0) { recovery( &msge ); } else { extrecovery( &msge ); DPRINT(-1,"From another Controller, No action yet.\n"); } /* prevent false starts from Sync glitches, controller reboots, or FPGA reloads */ cntrlFifoClearStartMode(); } }
bool PasswordRecoveryDialog::run(NetworkAuthenticationManager &mgr) { std::string errorMessage; std::string email; while (true) { if (!runDialog(email, errorMessage)) { LogOutRunnable logout(mgr); logout.executeWithUI(); return false; } PasswordRecoveryRunnable recovery(mgr, email); recovery.executeWithUI(); if (recovery.hasErrors()) { errorMessage = recovery.errorMessage(); LogOutRunnable logout(mgr); logout.executeWithUI(); continue; } ZLResourceKey boxKey("recoverySuccessfulBox"); const std::string message = ZLStringUtil::printf(ZLDialogManager::dialogMessage(boxKey), email); ZLDialogManager::Instance().informationBox(boxKey, message); return true; } }
void process(cv::Mat img) { last_image = img; tracker_mode current_mode = TRACKER_RECOVERY_MODE; for(size_t i = 0; current_modes.size(); ++i) { if(current_modes[i] > current_mode) { //FIXME tracking and locked mode are equivalent for now current_mode = current_modes[i]; break; } } switch(current_mode) { case TRACKER_RECOVERY_MODE: recovery(); break; case TRACKER_TRACKING_MODE: track(); break; case TRACKER_LOCKED_MODE: track(); //FIXME a bit hacky break; } }
//条件 //<条件>::=<表达式><关系运算符><表达式> AST_node condition(AST_node parent) { AST_node t = makeNode(CONDITION, parent); express(t); if (match(LEQ, t)) { } else if (match(LESS, t)) { } else if (match(EQL, t)) { } else if (match(GEQ, t)) { } else if (match(GREATER, t)) { } else if (match(NEQ, t)) { } else { error("Missing Relation Operator"); //错误恢复:跳至<表达式>的first集 recovery(5, PLUS, MINUS, IDENT, NUM, LPARENT); } express(t); return t; }
static int get_recovery_flag(void) { int primary_valid = 1, recovery_valid = 1; int magic_key; #ifdef CONFIG_OBM_PARAM_ADDR struct OBM2OSL *params = NULL; #endif magic_key = recovery_key_detect(); #ifdef CONFIG_OBM_PARAM_ADDR params = (struct OBM2OSL *)(uintptr_t)(*(u32 *)CONFIG_OBM_PARAM_ADDR); if (!params || params->signature != OBM2OSL_IDENTIFIER) { printf("WARING: no obm parameters !!!\n"); params = NULL; } else { magic_key |= (params->booting_mode == RECOVERY_MODE); primary_valid = params->primary.validation_status; recovery_valid = params->recovery.validation_status; } #endif return recovery(primary_valid, recovery_valid, magic_key, p_recovery_reg_funcs); }
/* reset appbar */ void recovery_usb_reset_appbar(LIBAROMA_WINDOWP win, USBMENU * var){ /* set appbar icon */ libaroma_ctl_bar_set_icon( recovery()->appbar,NULL,0,LIBAROMA_CTL_BAR_ICON_ARROW, 0 ); libaroma_ctl_bar_set_title( recovery()->appbar, "USB Mode", 0 ); libaroma_ctl_bar_set_subtitle( recovery()->appbar, NULL, 0 ); libaroma_ctl_bar_set_tools( recovery()->appbar,NULL,0 ); libaroma_ctl_bar_update(recovery()->appbar); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { mainLayout = new QVBoxLayout(); window = new QWidget(); gameView = new GameView(); gameModel = new GameModel(); topbar = new Topbar(); QObject::connect(gameModel, SIGNAL(sig_createMap(std::vector<std::shared_ptr<Tile> >)), gameView, SLOT(createWorldMap(std::vector<std::shared_ptr<Tile> >))); QObject::connect(gameModel, SIGNAL(sig_putEnemies(std::vector<std::shared_ptr<Enemy> >)), gameView, SLOT(createEnemies(std::vector<std::shared_ptr<Enemy> >))); QObject::connect(gameModel, SIGNAL(sig_putHealPck(std::vector<std::shared_ptr<Tile> >)), gameView, SLOT(createHealPcks(std::vector<std::shared_ptr<Tile> >))); QObject::connect(gameModel, SIGNAL(sig_getBoundary(int,int)), gameView, SLOT(setBoundary(int,int))); QObject::connect(gameModel, SIGNAL(sig_createProta(int,int)), gameView, SLOT(createProta(int,int))); QObject::connect(gameModel, SIGNAL(sig_changeProtaPos(int,int)), gameView, SLOT(changeProtaPos(int,int))); QObject::connect(gameModel, SIGNAL(sig_changeProtaHealth(float)), gameView, SLOT(changeProtaHealth(float))); QObject::connect(gameModel, SIGNAL(sig_changeProtaEnergy(float)), gameView, SLOT(changeProtaEnergy(float))); QObject::connect(gameModel,SIGNAL(sig_fightEnemy(std::shared_ptr<Enemy>)), gameView,SLOT(fightEnemy(std::shared_ptr<Enemy>))); QObject::connect(gameModel,SIGNAL(sig_recovery(std::shared_ptr<Tile>)), gameView,SLOT(recovery(std::shared_ptr<Tile>))); QObject::connect(gameModel, SIGNAL(sig_findPath(std::vector<std::shared_ptr<PathNode>>)), gameView, SLOT(highlightPath(std::vector<std::shared_ptr<PathNode>>))); QObject::connect(gameView, SIGNAL(sig_changeProtaPosbyMouse(int,int)), gameModel, SLOT(goDestinationByMouse(int,int))); QObject::connect(gameModel,SIGNAL(sig_stopMoving()), gameView, SLOT(stopMoving())); gameModel->initialGame(); mainLayout->addWidget(gameView); //------------------------test------------------- //gameModel->doAnimation(0,0,24,16); // gameView->removeHighlight(); mainLayout->addWidget(topbar); QObject::connect(gameModel,SIGNAL(sig_changeProtaHealth(float)), topbar,SLOT(changeHealthValue(float))); QObject::connect(gameModel,SIGNAL(sig_changeProtaEnergy(float)), topbar,SLOT(changeEnergyValue(float))); QObject::connect(topbar->getAnimation_slider(),SIGNAL(valueChanged(int)), gameModel,SLOT(setAnimationTime(int))); window->setLayout(mainLayout); this->setCentralWidget(window); }
/************************************************************* * * probHandler - Wait for Messages that indicate some problem * with the system. Then perform appropriate recovery. * * Author Greg Brissey 12-7-94 */ pHandler(MSG_Q_ID msges) { CNTLR_COMM_MSG msge; int *val; int bytes; void recovery(CNTLR_COMM_MSG *, int externflag); DPRINT(1,"pHandler :Server LOOP Ready & Waiting.\n"); FOREVER { markReady(PHANDLER_FLAGBIT); memset( &msge, 0, sizeof( CNTLR_COMM_MSG ) ); bytes = msgQReceive(pMsgesToPHandlr, (char*) &msge, sizeof( CNTLR_COMM_MSG ), WAIT_FOREVER); markBusy(PHANDLER_FLAGBIT); /* if aborted during the MRI read user byte, priorties maybe still high, so reset them. */ resetParserPriority(); /* use this order to retain priority relationship */ resetShandlerPriority(); errLogRet(LOGIT,debugInfo,"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"); errLogRet(LOGIT,debugInfo,"'%s': Exception from: -> '%s' <-, Type: %d, ErrorCode: %d \n", hostName, msge.cntlrId, msge.cmd, msge.errorcode); errLogRet(LOGIT,debugInfo,"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); /* they are all fatal so stop Spy if it was running */ if (enableSpyFlag > 0) { spyReport(); /* report CPU usage */ spyClkStop(); /* turn off spy clock interrupts, etc. */ } if (strcmp(msge.cntlrId,hostName) == 0) { recovery( &msge, 0 ); } else { recovery( &msge, 1 ); } /* prevent false starts from Sync glitches, controller reboots, or FPGA reloads */ cntrlFifoClearStartMode(); } }
/* main menu activity */ void recovery_usb(int parent_id,LIBAROMA_RECTP rect){ USBMENU var={0}; /* init window */ LIBAROMA_WINDOWP win = libaroma_ctl_fragment_new_window( recovery()->fragment, ID_USB_FRAGMENT ); if (win){ if (recovery_usb_init(win,&var)){ libaroma_ctl_fragment_set_active_window( recovery()->fragment, ID_USB_FRAGMENT, 1, 300, 0, recovery_usb_transition_cb, rect, NULL ); libaroma_ctl_bar_set_color( recovery()->appbar, RGB(555555), RGB(ffffff), 0 ); recovery_usb_reset_appbar(win,&var); recovery_statusbar_setcolor(RGB(555555)); recovery_usb_pool(win,&var); /* restore parent and delete usb fragment */ libaroma_ctl_fragment_set_active_window( recovery()->fragment, parent_id, 1, 300, 1, recovery_usb_transition_cb, NULL, rect ); libaroma_ctl_bar_set_color( recovery()->appbar, libaroma_colorget(NULL,recovery()->win)->primary, libaroma_colorget(NULL,recovery()->win)->primary_text, 0 ); recovery_statusbar_setcolor(libaroma_colorget(NULL,win)->primary); } else{ RLOG("recovery_usb: init window control failed"); libaroma_ctl_fragment_del_window(recovery()->fragment,ID_USB_FRAGMENT); } } else{ RLOG("recovery_usb: create main window failed"); } }
//for语句 //<for循环语句>::=for<标识符>:=<表达式>(downto|to)<表达式>do<语句> AST_node stat_for(AST_node t) { printf("----------------For Loop--------------\n"); t->ast_type = FORSTAT; match(FOR,t); if (!match(IDENT,t)) { error("Missing identifier for \"for-statement\""); recovery(1, BECOMES); } if (!match(BECOMES,t)) { error("Missing assign symbol"); recovery(5, PLUS, MINUS, IDENT, LPARENT, NUM); } express(t); if (!match(DOWNTO,t)) { if (!match(TO,t)) { error("Missing \"downto\" or \"to\""); recovery(5, IDENT, MINUS, PLUS, NUM, LPARENT); } } express(t); if (!match(DO,t)) { error("Missing do clause"); //因为可能是空语句,所以不需要错误恢复 //recovery(IDENT, IF, FOR, BEGIN, READ, WRITE); } AST_node stat = makeNode(STATS, t); statement(stat); printf("----------------End of For Loop--------------\n"); return t; }
//当循环语句 //<当循环语句>::=do<语句>while<条件> AST_node stat_do(AST_node t) { printf("----------------Do While Loop--------------\n"); t->ast_type = DOSTAT; match(DO,t); AST_node stat = makeNode(STATS, t); statement(stat); if (!match(WHILE,t)) { error("Missing while clause"); //错误恢复:跳至条件的first集 recovery(5, PLUS, MINUS, IDENT, NUM, LPARENT); } condition(t); printf("----------------End of Do While Loop--------------\n"); return t; }
void BiSortTree::ReadFile()//读文件构造二叉树 { int num=0,i=0; combine *p=NULL; FILE *in; char temp[MAXNAME]; if((in=fopen("in.txt","r+"))==NULL) return ; fscanf(in,"%d\n",&num); for(i=0;i<num;i++) { fgets(temp,MAXNAME,in); p=recovery(temp); AddBiTree(p); } fclose(in); }
//实在参数表 //<实在参数表>::='('<实在参数>{,<实在参数>}')' AST_node arg_list(AST_node parent) { AST_node t = makeNode(ARGLIST, parent); match(LPARENT,t); express(t); while (match(COMMA,t)) { //实在参数 //<实在参数>::=<表达式> express(t); } if (!match(RPARENT,t)) { error("Missing Right Parent"); recovery(3, RPARENT, SEMICOLON, END); } return t; }
ExtfsNode * FileNameRecovery::retrieve_inode(Directory * inode_dir, DirEntry * del_dirent, Node * parent, const std::string & name, inodes_t * _inter) { uint64_t inode_addr; ExtfsNode * node = NULL; __addr = inode_addr = inode_dir->getInodeByNumber(del_dirent->inode_value()); inode_dir->read(inode_addr, _inter); if (inode_dir->is_fucked_up()) { std::ostringstream oss; oss << del_dirent->inode_value(); new ExtfsRawDataNode(oss.str(), inode_dir->extfs()->SB()->inodes_struct_size(), inode_dir->extfs()->suspiscious_inodes(), inode_dir->extfs(), inode_addr + inode_dir->extfs()->SB()->offset() - __BOOT_CODE_SIZE); } if (retrieve_inode_direct(_inter, del_dirent->inode_value())) node = inode_dir->createNewNode(inode_addr, parent, name, _inter); else if (_journal) node = recovery(inode_addr / inode_dir->SB()->block_size(), inode_dir, del_dirent, _inter, parent); else { node = inode_dir->createNewNode(0, parent, (char *)name.c_str(), _inter); node->setDeleted(); return NULL; } if (node) { node->setDeleted(); node->set_i_nb(del_dirent->inode_value()); } if (inode_dir->i_list()->find(del_dirent->inode_value())) node = NULL; return node; }
//赋值语句 //<赋值语句>::=<标识符>:=<表达式>|<函数标识符>:=<表达式>|<标识符>'['<表达式>']':=<表达式> AST_node stat_assign(AST_node t) { //由于区别赋值语句与过程调用语句,所以IDENT已经被匹配 printf("---------------------Assignment--------------\n"); t->ast_type = ASSIGNSTAT; if (match(LBRACKET, t)) { express(t); if (!match(RBRACKET,t)) { error("Missing right bracket"); recovery(1, BECOMES); } } match(BECOMES,t); express(t); printf("----------------------End of Assignment---------\n"); return t; }
/* event loop */ byte recovery_usb_pool(LIBAROMA_WINDOWP win, USBMENU * var){ byte onpool=1; LIBAROMA_MSG msg; dword command; byte cmd; word id; byte param; do{ command=libaroma_window_pool(recovery()->win,&msg); cmd = LIBAROMA_CMD(command); id = LIBAROMA_CMD_ID(command); param = LIBAROMA_CMD_PARAM(command); if (msg.msg==LIBAROMA_MSG_KEY_SELECT){ if (msg.state==0){ RLOG("SCREENSHOOT AND EXIT"); libaroma_png_save( libaroma_fb()->canvas, "/sdcard/recovery_ss.png" ); onpool = 0; break; } } else if (cmd==LIBAROMA_CMD_HOLD){ printf("--- HOLD : %i - %i\n",id,param); } else if (cmd==LIBAROMA_CMD_CLICK){ if (id==ID_MENULIST){ printf("--- MENU: %i - %08X\n",msg.key,msg.d); onpool = 0; } else if (id==ID_APPBAR){ printf("--- APPBAR: p:%i, k:%i, y:%i\n",param,msg.key,msg.y); onpool = 0; } else{ printf("--- CLICK: %i - %i\n",id,param); } } } while(onpool); }
//条件语句 //<条件语句>::=if<条件>then<语句>|if<条件>then<语句>else<语句> AST_node stat_if(AST_node t) { printf("----------------If Statement--------------\n"); t->ast_type = IFSTAT; match(IF,t); condition(t); if (!match(THEN,t)) { error("Missing \"then\" clause"); recovery(8, IDENT, IF, DO, BEGIN, READ, WRITE, FOR, SEMICOLON, ELSE); } statement(t); if (match(ELSE,t)) { //有else分支 statement(t); } printf("----------------End of If--------------\n"); return t; }
void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFilenames) { assert(threshold<=1000); SecretRecovery recovery(threshold, new FileSink(outFilename)); vector_member_ptrs<FileSource> fileSources(threshold); SecByteBlock channel(4); int i; for (i=0; i<threshold; i++) { cout<<inFilenames[i]<<endl; fileSources[i].reset(new FileSource(inFilenames[i], false)); fileSources[i]->Pump(4); fileSources[i]->Get(channel, 4); fileSources[i]->Attach(new ChannelSwitch(recovery, string((char *)channel.begin(), 4))); } while (fileSources[0]->Pump(256)) { for (i=1; i<threshold; i++) fileSources[i]->Pump(256); for (i=0; i<threshold; i++) fileSources[i]->PumpAll(); } }
/************************************************************* * * probHandler - Wait for Messages that indecate some problem * with the system. Then perform appropriate recovery. * * Author Greg Brissey 12-7-94 */ pHandler(MSG_Q_ID msges) { EXCEPTION_MSGE msge; int *val; int bytes; void recovery(EXCEPTION_MSGE *); DPRINT(1,"pHandler :Server LOOP Ready & Waiting.\n"); FOREVER { markReady(PHANDLER_FLAGBIT); memset( &msge, 0, sizeof( EXCEPTION_MSGE ) ); bytes = msgQReceive(pMsgesToPHandlr, (char*) &msge, sizeof( EXCEPTION_MSGE ), WAIT_FOREVER); markBusy(PHANDLER_FLAGBIT); DPRINT3(1,"pHandler: recv: %d bytes, Exception Type: %d, Event: %d \n", bytes, msge.exceptionType, msge.reportEvent); recovery( &msge ); } }
void * rcvMessage(void * arg) { // receive message in chat from thread int sock = (int)arg; // client socket variable int seq_tmp = 0, data_tmp = 0; // sequence number, data_size variable timeout.tv_sec = 5; timeout.tv_usec = 0; FILE *fp; // file transfer pointer variable int i = 0, j = 0, cnt = 0; // normal variable(i = recv, j = for loop, cnt = acknowledge size while(1) { if((i = recv(sock, rcv_buf, sizeof(rcv_buf), 0)) > 0) { // recv message(i = 1024) rcv_buf[i] = '\0'; // last message buffer, close array fflush(stdout); // if buffer value exist, print it if(cnt > 0) { if(ack[cnt-1] > rwnd_size) { // if rwnd is full, don't receive message sprintf(snd_buf, "oversize"); send(sock, snd_buf, strlen(snd_buf), 0); continue; } } pthread_mutex_lock(&mutx); // rcvCnt is public variable in stack. so using lock&unlock rcvCnt += 1; pthread_mutex_unlock(&mutx); if(!strncmp(rcv_buf, "file", 4)) { // if recv message is 'file' printf("\n## Client wants file transport...\n"); i = recv(sock, rcv_buf, sizeof(rcv_buf), 0); // one more receive message rcv_buf[i] = '\0'; fflush(stdout); if((fp = fopen(rcv_buf, "r")) == NULL) { // and second message check printf("## File Not Found!!\n"); sprintf(snd_buf, "failed"); send(sock, snd_buf, strlen(snd_buf), 0); fp = NULL; continue; } else { // if second message is correct file name, printf("## File Found!! Transporting ...\n"); while(!feof(fp)) { fgets(rcv_buf,1024,fp); if(feof(fp)) break; strcat(file_buffer,rcv_buf); // file open and read each sentence, and append it 'file_buffer' } fclose(fp); sprintf(snd_buf, "success"); send(sock, snd_buf, strlen(snd_buf), 0); // signal "file transfer success" sleep(3); send(sock, file_buffer, strlen(file_buffer), 0); // give to client file content sleep(3); printf("\n## Server >> File IO is finish. New client waiting...\n"); printf("#####################################################\n"); fp = NULL; continue; } } else if(!strncmp(rcv_buf, "flowStart", 9)) { // if client message is 'flowStart' pthread_mutex_lock(&mutx); rcvCnt -= 1; // it isn't seq-data & ack relation, so rcvCnt value - 1 pthread_mutex_unlock(&mutx); printf("\n## Client wants flow control...\n"); i = recv(sock, rcv_buf, sizeof(rcv_buf), 0); // recv client size rcv_buf[i] = '\0'; fflush(stdout); printf("## server's size is 102, client's size is %s.\n## starting flow control !!\n", rcv_buf); sleep(1); flow_start(rcv_buf, (void *)sock); } else if(!strncmp(rcv_buf, "cgstStart", 9)) { // if client message is 'cgstStart' printf("\n## Client wants congestion control...\n"); while(1) { i = slow_start((void *)sock); // slow start !! if(i != 0) { // i variable is number when cwnd >= ssthresh, break printf("\n## Slow Start Finished. Congestion Avoid Start..\n"); while(1) { cgst_avoid((void *)sock); if(cgst_cnt >= 3) // in cgst_avoid method, cgst_cnt value + 1 when 1/10 MSS * 10 times run break; } printf("\n## Congestion Avoid Finished. Recovery Start...\n"); pthread_mutex_lock(&mutx); rcvCnt -= 1; cgst_cnt = 0; pthread_mutex_unlock(&mutx); while(1) { recovery((void *)sock); // fast recovery run!! if(cgst_cnt >= 3) break; } } i = 0; if(cgst_cnt >= 3) break; } } else if(!strncmp(rcv_buf, "quit", 4)) { // if receive message 'quit' pthread_mutex_lock(&mutx); clnt_number--; pthread_mutex_unlock(&mutx); printf("\n%s", rcv_buf); close(sock); // client socket closed } else { j = MSS; // give enough size to j value for(i = 0; i < strlen(rcv_buf); i++) { // client send (abcdefasdcasd sequence number = XX data size = XX) if(!isdigit(rcv_buf[i]) && rcv_buf[i] == '=') { // if not digit and correct = signal for(j = i+1; j < strlen(rcv_buf); j++) { // give next to = size to j value if(!isdigit(rcv_buf[j]) && rcv_buf[j] == '=') { i = j+1; // secondly correct = signal, give next to = size to i value, break break; } else if(isdigit(rcv_buf[j])) { // after first = signal, sequence number save to seq_tmp variable seq_tmp *= 10; seq_tmp += (rcv_buf[j] - '0'); } } } if(isdigit(rcv_buf[i]) && i > j) { // after second = signal, data size save to data_tmp variable data_tmp *= 10; data_tmp += (rcv_buf[i] - '0'); } } pthread_mutex_lock(&mutx); ack[cnt] = seq_tmp + data_tmp; // acknowledge save(ack is public variable in stack) rwnd_tmp[cnt] = data_tmp; // for increase rwnd threshold pthread_mutex_unlock(&mutx); cnt++; seq_tmp = 0; data_tmp = 0; printf("\n%s", rcv_buf); } } } }
bool ParseCmd(char *cmd) { char operate[100]; sscanf(cmd,"%s",operate); if (!strcmp(operate,"fmt")) { printf("Disk Formating. Please Wait.\n"); Format(); printf("Disk Format Compleated.\n"); } else if (!strcmp(operate,"dr")) { printf("%s\\ 的目录 \n\n",NowDirRoute); Dir(); } else if (!strcmp(operate,"cp")) { isEditing=true; printf("复制中,请稍候.\n"); char file1[1000],file2[1000]; sscanf(cmd,"%*s %s %s",file1,file2); //char dir[1000]; //char filename[10],extention[4]; //sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char filename[10],extention[4]; char filename2[10],extention2[4]; if (strchr(file1,':')) { char *p=strlen(file2)+file2; while(p!=file2) { if (*p=='\\') { break; } p--; } if (p!=file2) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(file2); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } //sscanf(file2,"%[^.]%*c%s",filename,extention); Copy(3,file1,0,filename,extention); } else if (strchr(file2,':')) { char *p=strlen(file1)+file1; while(p!=file1) { if (*p=='\\') { break; } p--; } if (p!=file1) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(file1); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } //sscanf(file2,"%[^.]%*c%s",filename,extention); Copy(2,filename,extention,file2,0); } else { if (!strchr(file1,'\\')&&!strchr(file2,'\\')) { sscanf(file1,"%[^.]%*c%s",filename,extention); sscanf(file2,"%[^.]%*c%s",filename2,extention2); Copy(1,filename,extention,filename2,extention2); } else { char *p=strlen(file1)+file1; while(p!=file1) { if (*p=='\\') { break; } p--; } if (p!=file1) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(file1); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } char ctmp[100]="c:\\"; strcat(ctmp,filename); strcat(ctmp,"_blegtmp."); strcat(ctmp,extention); Copy(2,filename,extention,ctmp,0); ChangeNowDir(OriDir); char *q=strlen(file2)+file2; while(q!=file2) { if (*q=='\\') { break; } q--; } if (q!=file2) { q++; sscanf(q,"%[^.]%*c%s",filename,extention); q--; *q=0; ChangeNowDir(file2); } else { sscanf(q,"%[^.]%*c%s",filename,extention); } Copy(3,ctmp,0,filename,extention); //ChangeNowDir(OriDir); } } ChangeNowDir(OriDir); printf("文件复制完成。\n"); isEditing=false; } else if (!strcmp(operate,"user")) { printf("请输入新用户名:"); while(1) { char tmp[100]; scanf("%s",tmp); if (strlen(tmp)<10) { strcpy(Username,tmp); break; } printf("用户名不能超过 10 个字符,请重新输入新用户名:"); } bool correct=false; int len=0; char tmp[20]; char tmp2[20]; memset(tmp2,0,20); memset(tmp,0,20); while(!correct) { printf("请输入新密码:"); while(1) { char ch=getch(); if (!isdigit(ch)&&!isalpha(ch)&&ch!=13) { continue; } if (ch==13) { if (len>=10) { printf("\n密码必须小于 10 个字符,请重新输入新密码:"); len=0; memset(tmp,0,20); continue; } else { printf("\n请再次输入新密码:"); len=0; break; } } else { tmp[len++]=ch; printf("*"); } } while(1) { char ch=getch(); if (!isdigit(ch)&&!isalpha(ch)&&ch!=13) { continue; } if (ch==13) { if (!strcmp(tmp,tmp2)) { printf("\n新密码已确认。\n"); getchar(); correct=true; break; } else { break; } } tmp2[len++]=ch; printf("*"); } } } else if(!strcmp(operate,"rm")) { char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } bool succ=Delete(1,filename,extention); if(succ) printf("一个文件已被删除.\n"); ChangeNowDir(OriDir); } else if (!strcmp(operate,"block")) { printf("文件所使用的数据块有:\n"); char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } BlockOfFile(filename,extention); ChangeNowDir(OriDir); } else if (!strcmp(operate,"rmdir")) { char dir[1000]; sscanf(cmd,"%*s %s",dir); bool succ=Delete(2,dir,0); if (succ) { printf("一个文件夹已被删除.\n"); } } else if (!strcmp(operate,"deleted")) { printf("回收站:\n"); Delete(3,0,0); } else if (!strcmp(operate,"type")) { char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } int fid=GetFileID(filename,extention); Display(1,fid); ChangeNowDir(OriDir); } else if (!strcmp(operate,"more")) { /* char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } int fid=GetFileID(filename,extention); Display(2,fid); ChangeNowDir(OriDir); */ //system("dir"); char filename[10],extention[4]; sscanf(cmd,"%*s %[^.]%*c%s",filename,extention); char tmp[100]; memset(tmp,0,100); strcat(tmp,"c:\\"); strcat(tmp,filename); strcat(tmp,"."); strcat(tmp,extention); Copy(2,filename,extention,tmp,0); char ccmd[100]="more "; strcat(ccmd,tmp); system(ccmd); } else if(!strcmp(operate,"att")) { char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } DisplayAttribute(filename,extention); ChangeNowDir(OriDir); } else if (!strcmp(operate,"help")) { } else if (!strcmp(operate,"cd")) { char Dir[1000]; sscanf(cmd,"%*s %s",Dir); ChangeNowDir(Dir); } else if (!strcmp(operate,"close")) { Close(); } else if (!strcmp(operate,"new")) { char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } bool succ=New(1,filename,extention); if (succ) { printf("文件创建成功。\n"); } ChangeNowDir(OriDir); } else if (!strcmp(operate,"aaa")) { printf("%d\n",TotalFileNum); printf("%s\n",NowDirRoute); } else if (!strcmp(operate,"newdir")) { char filename[10]; sscanf(cmd,"%*s %s",filename); bool succ=New(2,filename,0); if (succ) { printf("目录创建成功。\n"); } } else if (!strcmp(operate,"editw")) { isEditing=true; char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } Edit(1,filename,extention); printf("1 Files Saved.\n"); ChangeNowDir(OriDir); isEditing=false; } else if (!strcmp(operate,"edita")) { isEditing=true; char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } Edit(2,filename,extention); printf("1 Files Saved.\n"); ChangeNowDir(OriDir); isEditing=false; } else if (!strcmp(operate,"rc")) { char dir[1000]; char filename[10],extention[4]; sscanf(cmd,"%*s %s",dir); char OriDir[1000]; strcpy(OriDir,NowDirRoute); char *p=strlen(dir)+dir; while(p!=dir) { if (*p=='\\') { break; } p--; } if (p!=dir) { p++; sscanf(p,"%[^.]%*c%s",filename,extention); p--; *p=0; ChangeNowDir(dir); } else { sscanf(p,"%[^.]%*c%s",filename,extention); } recovery(filename,extention); printf("文件已恢复。\n"); ChangeNowDir(OriDir); } else if (!strcmp(operate,"space")) { // #ifdef _1M_ // printf("总空间: 1048576 Bytes.可用空间: %d Bytes.剩余空间: %d Bytes.\n",FDBNum*4096,FreeFDBNum*4096); // #endif #ifdef _1G_ printf("总空间: 1073741824 Bytes.可用空间: %d Bytes.剩余空间: %d Bytes.\n",FDBNum*4096,FreeFDBNum*4096); #endif } else if (!strcmp(operate,"tree")) { printf("%s 的文件结构树:\n",NowDirRoute); printf(".\n"); Tree(1,NowDirFid); } else { printf("illegal instruction\n"); } return true; }
int main(int argc, char**argv) { int sfd,ssfd; if (argc!=5) { fprintf(stdout,"usage: client <IP> <port> <port> <debug>"); exit(1); } if (strcmp(argv[4],"-debug")==0) flag=1; //commented out to hopefully make it work with static compiling /* char hostname[100]; struct hostent *h; gethostname(hostname, 100); fprintf(stdout,"hostname: %s\n", hostname); if ((h = gethostbyname(hostname))!=NULL) { fprintf(stdout,"ip address: %s\n", inet_ntoa(*((struct in_addr *)h->h_addr))); } */ recover: fprintf(stdout,"con_server() to %s on port %s\n", argv[1], argv[2]); sfd=con_server(atoi(argv[2]), argv[1]); set_sockopt(sfd); fprintf(stdout,"con_server() to %s on port %s\n", argv[1], argv[3]); ssfd=con_server(atoi(argv[3]), argv[1]); if (flag==1) fprintf(stdout,"connection established!\n"); char num[10]; char clientID[22]; char filename[100]; int result; char *msg; char *taskID; char lifetime[]="10\n"; pid_t pid; int n; /*n=send(sfd, lifetime, sizeof(lifetime), 0); if (n<0) { fprintf(stdout, "main: send lifetime error\n"); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } char acknoledge[10]; memset(acknoledge, '\0', 10); read(sfd,acknoledge,sizeof(acknoledge)); printf("acknoledge: %s\n", acknoledge); fflush(stdout);*/ while (1) { memset(filename,'\0',sizeof(filename)); memset(clientID,'\0',sizeof(clientID)); memset(num, '\0', sizeof(num)); if (flag==1) { fprintf(stdout,"main: receiving from server\n"); fprintf(stdout,"main: sizeof clientID: %d\n", sizeof(clientID)); } int numBytes=0; int numBytesAll = 0; if (flag==1) { fprintf(stdout,"main:waiting to received %d bytes...\n", sizeof(clientID)); } while (numBytesAll < sizeof(clientID)) { numBytes = read(sfd,clientID,sizeof(clientID)); if (numBytes<0) { fprintf(stdout,"main: Receive clientID error after %d bytes received, when it was expecting %d...\n", numBytesAll, sizeof(clientID)); fprintf(stdout,"main: error description: %d\n", errno); recovery(sfd, ssfd); goto recover; } else if (numBytes==0) { fprintf(stdout,"main: Receive clientID error after %d bytes received, when it was expecting %d...\n", numBytesAll, sizeof(clientID)); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } else { if (flag == 1) fprintf(stdout,"main: Received %d bytes...\n", numBytes); } numBytesAll += numBytes; if (numBytesAll == 3) { if (strncasecmp(clientID, "end", 3)==0) { fprintf(stdout, "main: receive end notice, exit\n"); //should shut down gracefully... closing all sockets... //exit(0); goto recover; } } } if (flag==1) { fprintf(stdout,"main:just received %d bytes...\n", numBytesAll); } fflush(stdout); if (flag==1) { fprintf(stdout,"main: clientID: %s\n", clientID); } numBytesAll = 0; if (flag==1) { fprintf(stdout,"main:waiting to received %d bytes...\n", sizeof(num)); } while (numBytesAll < sizeof(num)) { numBytes = read(sfd,num,sizeof(num)); if (numBytes<0) { fprintf(stdout,"main: Receive task size error after %d bytes received, when it was expecting %d...\n", numBytesAll, sizeof(num)); fprintf(stdout,"main: error description: %d\n", errno); recovery(sfd, ssfd); goto recover; } else if (numBytes==0) { fprintf(stdout,"main: Receive task size error after %d bytes received, when it was expecting %d...\n", numBytesAll, sizeof(clientID)); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } else { if (flag == 1) fprintf(stdout,"main: Received %d bytes...\n", numBytes); } numBytesAll += numBytes; } if (flag==1) { fprintf(stdout,"main:just received %d bytes...\n", numBytesAll); } int taskSize=atoi(num); msg=malloc(sizeof(char)*(taskSize+1)); memset(msg,'\0',sizeof(msg)); if (msg==NULL) { fprintf(stdout,"main: allocate memory failed\n"); exit (1); } if (flag==1) { fprintf(stdout,"main:waiting to receive task description of %d bytes...\n", taskSize); //fprintf(fp,"main:received: %s\n", msg); } char buffer[10240]; numBytesAll = 0; while (numBytesAll < taskSize) { memset(buffer, 0, 10240); numBytes = read(sfd,buffer,taskSize); strcat(msg, buffer); if (numBytes<0) { fprintf(stdout,"main: Receive task failed after %d bytes received, when it was expecting %d...\n", numBytesAll, taskSize); fprintf(stdout,"main: error description: %d\n", errno); recovery(sfd, ssfd); goto recover; } else if (numBytes==0) { fprintf(stdout,"main: Receive task failed after %d bytes received, when it was expecting %d...\n", numBytesAll, sizeof(clientID)); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } else { if (flag == 1) fprintf(stdout,"main: Received %d bytes...\n", numBytes); } numBytesAll += numBytes; } if (flag==1) { fprintf(stdout,"main:jst received %d bytes...\n", numBytesAll); } if (flag==1) { fprintf(stdout,"main:received: %s\n", msg); } //commented out ACK numBytes=send(sfd, ACK,strlen(ACK),0); if (numBytes < 0) { fprintf(stdout,"main: Sent ACK %s failed\n", ACK); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } else { if (flag == 1) fprintf(stdout,"main: Sent ACK %s successful (%d)\n", ACK, numBytes); } fflush(stdout); taskID = getTaskID(msg); int exitCode; exitCode = parseExec(msg); free(msg); numBytes = sendResults(taskID, exitCode, argv, ssfd, sfd); if (numBytes < 0) { fprintf(stdout,"main: Send results failed\n"); //fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } } }
//语句 AST_node statement(AST_node parent) { AST_node t = makeNode(STATEMENT, parent); if (symbol == IDENT) { //赋值语句或者过程调用语句 //<赋值语句>::=<标识符>:=<表达式>|<函数标识符>:=<表达式>|<标识符>'['<表达式>']':=<表达式> //<过程调用语句>::=<标识符>[<实在参数表>] match(IDENT,t); if (symbol == BECOMES || symbol == LBRACKET) { //赋值语句 stat_assign(t); } else if (symbol == LPARENT || symbol == SEMICOLON || symbol == END //过程调用语句在end前,可以没有分号 ) { //过程调用语句 stat_procedure(t); } else { error("Unknown Statement!"); recovery(2, SEMICOLON, END); } } else if (symbol == IF) { //条件语句 //<条件语句>::=if<条件>then<语句>|if<条件>then<语句>else<语句> stat_if(t); } else if (symbol == DO) { //当循环语句 //<当循环语句>::=do<语句>while<条件> stat_do(t); } else if (symbol == FOR) { //for循环语句 //<for循环语句>::=for<标识符>:=<表达式>(downto|to)<表达式>do<语句>//步长为1 stat_for(t); } else if (symbol == BEGIN) { //复合语句 //<复合语句>::=begin<语句>{;<语句>}end stat_list(t); } else if (symbol == READ) { //读语句 //<读语句>::=read'('<标识符>{,<标识符>}')' stat_read(t); } else if (symbol == WRITE) { //写语句 //<写语句>::=write'('<字符串>,<表达式>')'|write'('<字符串>')'|write'('<表达式>')' stat_write(t); } else { //空语句 t->ast_type = EMPTY; printf("----------------Empty Statement--------------\n"); } return 0; }
int main(int argc, char**argv) { int sfd,ssfd; char num[10]; char clientID[22]; char filename[100]; int result; int taskSize; int exitCode; int numBytes; char *msg; char *taskID; char ACK[]="OK\n"; char lifetime[]="10\n"; Task *task; char *back; if (argc!=5) { fprintf(stdout,"usage: client <IP> <port> <port> <debug>"); exit(1); } if (strcmp(argv[4],"-debug")==0) flag=1; recover: if(flag == 1) fprintf(stdout,"con_server() to %s on port %s\n", argv[1], argv[2]); sfd=con_server(atoi(argv[2]), argv[1]); set_sockopt(sfd); if(flag == 1) fprintf(stdout,"con_server() to %s on port %s\n", argv[1], argv[3]); ssfd=con_server(atoi(argv[3]), argv[1]); if (flag==1) fprintf(stdout,"connection established!\n"); /*numBytes=send(sfd, lifetime, sizeof(lifetime), 0); if (numBytes<0) { fprintf(stdout, "main: send lifetime error\n"); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; }*/ while (1) { task = (Task *)malloc(sizeof(Task)); if (task==NULL) printf("failed to allocate memory in main loop\n"); memset(filename,'\0',sizeof(filename)); memset(clientID,'\0',sizeof(clientID)); memset(num, '\0', sizeof(num)); /*receive clientID*/ recv_wrapper(sfd, ssfd, clientID, 22); if (flag==1) { fprintf(stdout,"main: clientID: %s\n", clientID); } /*receive size of task*/ recv_wrapper(sfd, ssfd, num, 10); if (flag==1) { fprintf(stdout,"main: size_of_task: %s\n", num); } /*allocate memory for task description*/ taskSize=atoi(num); msg=malloc(sizeof(char)*(taskSize+1)); if (msg==NULL) { fprintf(stdout,"main: allocate memory failed\n"); exit (1); } memset(msg,'\0',taskSize+1); /*receive task description*/ recv_wrapper(sfd, ssfd, msg, taskSize); if (flag==1) { fprintf(stdout,"main:received: %s\n", msg); } /*send acknoledgement for the received task*/ numBytes=send(sfd, ACK,strlen(ACK),0); if (numBytes < 0) { fprintf(stdout,"main: Sent ACK %s failed\n", ACK); fprintf(stdout,"main: error description: EOF\n"); recovery(sfd, ssfd); goto recover; } else { if (flag == 1) fprintf(stdout,"main: Sent ACK %s successful (%d)\n", ACK, numBytes); } parseExec(msg, task); exitCode = run_task(task); /*send results back to Falkon service*/ numBytes = sendResults(task, ssfd, sfd); if (numBytes < 0) { fprintf(stdout,"main: Send results failed\n"); recovery(sfd, ssfd); goto recover; } //free(task->taskID); //free(task->command); //free(task->directory); free(task); free(msg); //exit(1); } }