void SetServerAddr(SocketEndpoint &endpoint) { free(hostname); StringBuffer ipname; endpoint.getIpText(ipname); hostname = strdup(ipname.str()); hostport = endpoint.port; }
virtual void Bind(SocketEndpoint &endpoint,int qsize) { if (serversock) { serversock->Release(); serversock = NULL; } try { StringBuffer ipname; endpoint.getIpText(ipname); serversock = ISocket::create_ip(endpoint.port,ipname.str(),qsize); } catch (IJSOCK_Exception *e) { int hrpcerr; switch (e->errorCode()) { case JSOCKERR_port_in_use: hrpcerr = HRPCERR_transport_port_in_use; break; default: throw; } THROWHRPCEXCEPTIONEXC(hrpcerr,e); e->Release(); } assertex(serversock); }
void TransferServer::deserializeAction(MemoryBuffer & msg, unsigned action) { SocketEndpoint ep; ep.deserialize(msg); if (!ep.isLocal()) { StringBuffer host, expected; queryHostIP().getIpText(host); ep.getIpText(expected); throwError2(DFTERR_WrongComputer, expected.str(), host.str()); } srcFormat.deserialize(msg); tgtFormat.deserialize(msg); msg.read(calcInputCRC); msg.read(calcOutputCRC); deserialize(partition, msg); msg.read(numParallelSlaves); msg.read(updateFrequency); msg.read(replicate); msg.read(mirror); msg.read(isSafeMode); srand((unsigned)get_cycles_now()); int adjust = (rand() * rand() * rand()) % updateFrequency - (updateFrequency/2); lastTick = msTick() + adjust; StringBuffer localFilename; if (action == FTactionpull) { partition.item(0).outputName.getPath(localFilename); LOG(MCdebugProgress, unknownJob, "Process Pull Command: %s", localFilename.str()); } else { partition.item(0).inputName.getPath(localFilename); LOG(MCdebugProgress, unknownJob, "Process Push Command: %s", localFilename.str()); } LOG(MCdebugProgress, unknownJob, "Num Parallel Slaves=%d Adjust=%d/%d", numParallelSlaves, adjust, updateFrequency); LOG(MCdebugProgress, unknownJob, "replicate(%d) mirror(%d) safe(%d) incrc(%d) outcrc(%d)", replicate, mirror, isSafeMode, calcInputCRC, calcOutputCRC); displayPartition(partition); unsigned numProgress; msg.read(numProgress); for (unsigned i = 0; i < numProgress; i++) { OutputProgress & next = *new OutputProgress; next.deserializeCore(msg); progress.append(next); } if (msg.remaining()) msg.read(throttleNicSpeed); if (msg.remaining()) msg.read(compressedInput).read(compressOutput); if (msg.remaining()) msg.read(copyCompressed); if (msg.remaining()) msg.read(transferBufferSize); if (msg.remaining()) msg.read(encryptKey).read(decryptKey); if (msg.remaining()) { srcFormat.deserializeExtra(msg, 1); tgtFormat.deserializeExtra(msg, 1); } ForEachItemIn(i1, progress) progress.item(i1).deserializeExtra(msg, 1); LOG(MCdebugProgress, unknownJob, "throttle(%d), transferBufferSize(%d)", throttleNicSpeed, transferBufferSize); PROGLOG("compressedInput(%d), compressedOutput(%d), copyCompressed(%d)", compressedInput?1:0, compressOutput?1:0, copyCompressed?1:0); PROGLOG("encrypt(%d), decrypt(%d)", encryptKey.isEmpty()?0:1, decryptKey.isEmpty()?0:1); //---Finished deserializing --- displayProgress(progress); totalLengthRead = 0; totalLengthToRead = 0; ForEachItemIn(idx, partition) totalLengthToRead += partition.item(idx).inputLength; }