void ejLexCloseScript(ej_t* ep) { ejinput_t *ip; a_assert(ep); ip = ep->input; a_assert(ip); if (ip->putBackToken) { bfree(B_L, ip->putBackToken); ip->putBackToken = NULL; } ip->putBackTokenId = 0; if (ip->line) { bfree(B_L, ip->line); ip->line = NULL; } ringqClose(&ip->tokbuf); ringqClose(&ip->script); bfree(B_L, ip); }
void socketSetBufferSize(int sid, int in, int line, int out) { socket_t *sp; if ((sp = socketPtr(sid)) == NULL) { return; } if (in >= 0) { ringqClose(&sp->inBuf); in++; ringqOpen(&sp->inBuf, in, in); } if (line >= 0) { ringqClose(&sp->lineBuf); line++; ringqOpen(&sp->lineBuf, line, line); } if (out >= 0) { ringqClose(&sp->outBuf); out++; ringqOpen(&sp->outBuf, out, out); } }
void socketFree(int sid) { socket_t *sp; char_t buf[256]; int i; if ((sp = socketPtr(sid)) == NULL) { return; } /* * To close a socket, remove any registered interests, set it to * non-blocking so that the recv which follows won't block, do a * shutdown on it so peers on the other end will receive a FIN, * then read any data not yet retrieved from the receive buffer, * and finally close it. If these steps are not all performed * RESETs may be sent to the other end causing problems. */ socketRegisterInterest(sp, 0); if (sp->sock >= 0) { socketSetBlock(sid, 0); /**************************** HANHUI ***************************/ /* if (shutdown(sp->sock, 1) >= 0) { recv(sp->sock, buf, sizeof(buf), 0); } */ shutdown(sp->sock, SHUT_RDWR); /**************************** HANHUI ***************************/ #if (defined (WIN) || defined (CE)) closesocket(sp->sock); #else close(sp->sock); #endif } ringqClose(&sp->inBuf); ringqClose(&sp->outBuf); ringqClose(&sp->lineBuf); bfree(B_L, sp); socketMax = hFree((void***) &socketList, sid); /* * Calculate the new highest socket number */ socketHighestFd = -1; for (i = 0; i < socketMax; i++) { if ((sp = socketList[i]) == NULL) { continue; } socketHighestFd = max(socketHighestFd, sp->sock); } }