static HANDLE waitSockRead;
static HANDLE sockListLock;
static UdpState *sockList;
-static UdpState *sockTail;
#endif /* ! WIN32 */
Tcl_AppendResult(interp, channelName, (char *)NULL);
#ifdef WIN32
WaitForSingleObject(sockListLock, INFINITE);
- if (sockList == NULL) {
- sockList = statePtr;
- sockTail = statePtr;
- } else {
- sockTail->next = statePtr;
- sockTail = statePtr;
- }
+ statePtr->next = sockList;
+ sockList = statePtr;
- UDPTRACE("Append %d to sockList\n", statePtr->sock);
+ UDPTRACE("Added %d to sockList\n", statePtr->sock);
SetEvent(sockListLock);
SetEvent(waitForSock);
#endif
UdpState *statePtr;
Tcl_Time blockTime = { 0, 0 };
- UDPTRACE("setupProc\n");
+ /* UDPTRACE("setupProc\n"); */
if (!(flags & TCL_FILE_EVENTS)) {
return;
#endif
PacketList *p;
- UDPTRACE("checkProc\n");
+ /* UDPTRACE("checkProc\n"); */
/* synchronized */
WaitForSingleObject(sockListLock, INFINITE);
*/
sockList = NULL;
- sockTail = NULL;
waitForSock = CreateEvent(NULL, FALSE, FALSE, NULL);
waitSockRead = CreateEvent(NULL, FALSE, FALSE, NULL);
sockListLock = CreateEvent(NULL, FALSE, TRUE, NULL);
Tcl_Obj **objv;
UdpState *statePtr = (UdpState *) instanceData;
#ifdef WIN32
- UdpState *statePre, *searchPtr;
+ UdpState *tmp, *p;
WaitForSingleObject(sockListLock, INFINITE);
#endif /* ! WIN32 */
sock = statePtr->sock;
#ifdef WIN32
+
/* remove the statePtr from the list */
- for (searchPtr = sockList, statePre = sockList;
- searchPtr != NULL;
- statePre=statePtr, searchPtr=searchPtr->next) {
- if (searchPtr->sock == sock) {
- UDPTRACE("Remove %d from the list\n", sock);
- if (searchPtr == sockList) {
- sockList = sockList->next;
- } else {
- statePre->next = searchPtr->next;
- if (sockTail == searchPtr)
- sockTail = statePre;
- }
- }
+ for (tmp = p = sockList; p != NULL; tmp = p, p = p->next) {
+ if (p->sock == sock) {
+ UDPTRACE("Remove %d from the list\n", p->sock);
+ if (p == sockList) {
+ sockList = sockList->next;
+ } else {
+ tmp->next = p->next;
+ }
+ }
}
+
#endif /* ! WIN32 */
/*