extern void BeginDB_Redirect( DBG_Struct *dbg) { ENTER_FUNC; if ( dbg->redirect == NULL ) return; if ( dbg->fpLog != NULL ) { SendPacketClass(dbg->fpLog,RED_BEGIN); ON_IO_ERROR(dbg->fpLog,badio); dbg->ticket_id = RecvInt(dbg->fpLog); if (dbg->ticket_id == 0 ) { Warning("Illegal ticket_id."); } } else { dbg->ticket_id = 0; } if ( dbg->redirectData != NULL ) { LBS_EmitStart(dbg->redirectData); LBS_EmitStart(dbg->checkData); } LEAVE_FUNC; return; badio: Warning("dbredirector connection is lost."); return; }
/*---------------- // return value // -1 : recv error // -2 : invalid key // 0 : O.K. //----------------*/ int CComm::RecvKey() { int key; key = RecvInt(); if (key != KEY) { LOG("Protocol Error (invalid key)"); return -2; } return 0; }
std::vector<int> s13WXWServer::RecvInt () { std::vector<int> aryReturn; unsigned int uiSocketsLength = aryClientSockets.size (); aryReceivedFrom.clear (); for (unsigned int uiIdx = 0; uiIdx < uiSocketsLength; uiIdx++) { int adtReturn = RecvInt (aryClientSockets.at (uiIdx)); aryReturn.push_back (adtReturn); aryReceivedFrom.push_back (uiIdx); } return (aryReturn); }
PacketClass SYSDB_GetDataAll(NETFILE *fp, int *size, ValueStruct *vals) { PacketClass rc; LargeByteString *buf; rc = SESSION_CONTROL_NG; buf = NewLBS(); SendPacketClass(fp, SYSDATA_SYSDB); ON_IO_ERROR(fp, badio); SendPacketClass(fp, SYSDB_GET_DATA_ALL); ON_IO_ERROR(fp, badio); rc = RecvPacketClass(fp); *size = RecvInt(fp); RecvLBS(fp, buf); NativeUnPackValue(NULL, LBS_Body(buf), vals); badio: FreeLBS(buf); return rc; }
TError RecvZero() const { int zero; return RecvInt(zero); }
int SeisPipe2D(DsuTask *zz) { int nt,nx,nz,nw,ntpad,ntfft; int it,ix,iz,izz,iw,iw0,iw1,iw2,iw3,iwmin,iwmax; int nfreqs,verbose; float dt,dx,dy,dz,dw; float freqs[4],fw,w,scale,fftscl; float *p, **v, *wdxov,*sx; complex *cpx; float **qx; void *TabInfo; eTable *et; char msg[80]; int info, ToTid, MasterTid; int sz, pz, pei; int SeisIntPars[20]; float SeisFloPars[20]; /* Receive process control information */ MsgLog(zz, "Receiving Control info ... " ); MasterTid = RecvInt(SeisIntPars, 2, -1, MsgCntl); pei = SeisIntPars[0]; ToTid = SeisIntPars[1]; MsgLog(zz, " Ready \n"); /* Receive: efile and other pars ... */ MsgLog(zz, "Receiving parameters ..." ); TabInfo = RecvBytes(-1, MsgTable); RecvFI(SeisFloPars, 10, SeisIntPars, 10, -1, -1); MsgLog(zz, " Ready \n" ); /* get integer parameters */ nt = SeisIntPars[0]; nx = SeisIntPars[1]; nz = SeisIntPars[2]; ntpad = SeisIntPars[3]; verbose = SeisIntPars[4]; sz = SeisIntPars[5]; pz = SeisIntPars[6]; /* get Floating point parameters */ dt = SeisFloPars[0]; dx = SeisFloPars[1]; dz = SeisFloPars[2]; freqs[0] = SeisFloPars[3]; freqs[1] = SeisFloPars[4]; freqs[2] = SeisFloPars[5]; freqs[3] = SeisFloPars[6]; sz = nz / pz; if (pei == (pz - 1)) sz += nz % pz; sprintf(msg, "Receiving Velocity info (pei = %d, sz = %d) ... ", pei, sz); MsgLog(zz,msg); v = alloc2float(nx, sz); for (iz=0; iz<sz; ++iz) RecvFloat(v[iz], nx, -1, MsgVel); MsgLog(zz, " Ready \n" ); /* determine frequency w sampling */ ntfft = npfar(nt+ntpad); nw = ntfft/2+1; dw = 2.0*PI/(ntfft*dt); iwmin = MAX(0,MIN(nw-1,NINT(2.0*PI*freqs[0]/dw))); iwmax = MAX(0,MIN(nw-1,NINT(2.0*PI*freqs[3]/dw))); /* read extrapolator table */ et = ezread(TabInfo); /* pret(zz -> fp_log, et); */ /* allocate workspace */ MsgLog(zz, "Allocating space ... "); qx = alloc2float(nx,sz); sx = alloc1float(nx); wdxov = alloc1float(nx); cpx = alloc1complex(nx); MsgLog(zz, " Ready \n"); sprintf(msg, "Process (%d) starting loop on depth steps(%d,%d)\n", pei, pei*(nz/pz), pei*(nz/pz) + sz); MsgLog(zz, msg); /* Cleanup qx */ for (iz=0; iz<sz; ++iz) for (ix=0; ix<nx; ++ix) qx[iz][ix] = 0.0; /* loop over frequencies w */ for (iw=iwmin,w=iwmin*dw; iw<iwmax; ++iw,w+=dw) { if (verbose && !(iw%1)) { sprintf(msg, "\t%d/%d\n",iw,iwmax); MsgLog(zz, msg); } /* load wavefield */ RecvCplx(cpx, nx, -1, MsgSlice); /* loop over depth steps nz */ for (iz=0; iz<sz; ++iz) { /* compute 2.0*dx/v(x) and zero migrated data */ for (ix=0; ix<nx; ix++) sx[ix] = 2.0*dx/v[iz][ix]; /* make w*dx/v(x) */ for (ix=0; ix<nx; ++ix) wdxov[ix] = w*sx[ix]; /* extrapolate wavefield */ etextrap(et,nx,wdxov,cpx); /* accumulate migrated data */ for (ix=0; ix<nx; ++ix) qx[iz][ix] += cpx[ix].r; } /* Send down the wavefield */ if ( pei != (pz -1)) SendCplx(cpx, nx, ToTid, MsgSlice); } /* End of loop for iw */ for (iz=0; iz<sz; iz++) { izz = pei*(nz/pz) + iz; if (verbose) { sprintf(msg, "Sending values for iz = %d\n",izz); MsgLog(zz, msg); } SendFI(qx[iz], nx, &izz, 1, MasterTid, MsgDepth); } sprintf(msg, "End of processing for (%d)\n",pei); MsgLog(zz, msg); /* free workspace */ free1float(sx); free1float(wdxov); free2float(v); free2float(qx); free1complex(cpx); pvm_exit(); return(0); }
static SessionData * ReadTerminal( NETFILE *fp, SessionData *data) { LD_Node *ld; Bool fExit; int c; LargeByteString *scrdata; int i; ENTER_FUNC; fExit = FALSE; while (!fExit) { switch (c = RecvPacketClass(fp)) { case WFC_DATA: dbgmsg("recv DATA"); if (data != NULL) { RecvnString(fp,SIZE_NAME,data->hdr->window); ON_IO_ERROR(fp,badio); RecvnString(fp,SIZE_NAME,data->hdr->widget); ON_IO_ERROR(fp,badio); RecvnString(fp,SIZE_NAME,data->hdr->event); ON_IO_ERROR(fp,badio); data->w.sp = RecvInt(fp); ON_IO_ERROR(fp,badio); for (i=0;i<data->w.sp ;i++) { data->w.s[i].puttype = RecvChar(fp); ON_IO_ERROR(fp,badio); RecvnString(fp,SIZE_NAME,data->w.s[i].window); ON_IO_ERROR(fp,badio); } dbgprintf("window = [%s]",data->hdr->window); dbgprintf("widget = [%s]",data->hdr->widget); dbgprintf("event = [%s]",data->hdr->event); ld = g_hash_table_lookup(ComponentHash,data->hdr->window); if (ld != NULL) { dbgprintf("ld = [%s]",ld->info->name); dbgprintf("window = [%s]",data->hdr->window); scrdata = GetScreenData(data,data->hdr->window); if (scrdata != NULL) { SendPacketClass(fp,WFC_OK); ON_IO_ERROR(fp,badio); dbgmsg("send OK"); if (RecvPacketClass(fp) == WFC_DATA) { RecvLBS(fp,scrdata);ON_IO_ERROR(fp,badio); } data->hdr->puttype = SCREEN_NULL; } else { Error("invalid window [%s]",data->hdr->window); } if (data->ld != ld) { ChangeLD(data,ld); } } else { Error("component [%s] not found.",data->hdr->window); fExit = TRUE; } } else { fExit = TRUE; } break; case WFC_OK: dbgmsg("OK"); fExit = TRUE; break; case WFC_END: dbgmsg("END"); if ((ld = g_hash_table_lookup(APS_Hash, "session")) != NULL) { strncpy(data->hdr->window,"session_end", sizeof(data->hdr->window)); data->hdr->widget[0] = 0; sprintf(data->hdr->event,"SESSIONEND"); data->hdr->puttype = SCREEN_NULL; ChangeLD(data,ld); data->status = SESSION_STATUS_END; } else { data->status = SESSION_STATUS_ABORT; } fExit = TRUE; break; default: Warning("Invalid PacketClass in ReadTerminal [%X]", c); SendPacketClass(fp,WFC_NOT);ON_IO_ERROR(fp,badio); fExit = TRUE; data->status = SESSION_STATUS_ABORT; break; } } badio: LEAVE_FUNC; return(data); }
/*---------------- // return value // -1 : error // 1 : request submit // 2 : request test // 3 : request grade // 0 : keep alive CHECK // //----------------*/ int CComm::RecvJob(string * task, string * language) { char buf[1024]; bzero(buf, sizeof(buf)); int nread = readline(buf, 1024); if (nread < 0) { close(mSock); return -1; } else if (nread == 0) //0815 { LOG("Connection closed!"); close(mSock); return -1; } int len; LOG("[RECV:%s]", buf); char source_path[256]; sprintf(source_path, "%s%s", TEMP_PATH, SOURCE_FILE); if (strncasecmp(buf, "REQUEST SUBMIT", strlen("REQUEST SUBMIT")) == 0) { if (ParseTaskData(buf + strlen("REQUEST SUBMIT"), task, language) < 0) return -1; if (RecvKey() < 0) return -1; len = RecvInt(); if (len < 0) return -1; if (RecvFile(len, source_path) < 0) return -1; return 1; } else if (strncasecmp(buf, "REQUEST TEST", strlen("REQUEST TEST")) == 0) { if (ParseTaskData(buf + strlen("REQUEST TEST"), task, language) < 0) return -1; if (RecvKey() < 0) return -1; len = RecvInt(); if (len < 0) return -1; if (RecvFile(len, source_path) < 0) return -1; if (RecvKey() < 0) return -1; len = RecvInt(); if (len < 0) return -1; if (RecvFile(len, TEST_DATA) < 0) return -1; return 2; } else if (strncasecmp(buf, "REQUEST GRADE", strlen("REQUEST GRADE")) == 0) { if (ParseTaskData(buf + strlen("REQUEST GRADE"), task, language) < 0) return -1; if (RecvKey() < 0) return -1; len = RecvInt(); if (len < 0) return -1; if (RecvFile(len, source_path) < 0) return -1; return 3; } else if (strncasecmp(buf, "\n", 1) == 0) { return 0; } else { LOG("Protocol Error [received:%s]", buf); close(mSock); return -1; } }