Rev 3725 | Rev 4265 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3725 | Rev 3908 | ||
---|---|---|---|
Line 13... | Line 13... | ||
13 | ;; GNU GENERAL PUBLIC LICENSE ;; |
13 | ;; GNU GENERAL PUBLIC LICENSE ;; |
14 | ;; Version 2, June 1991 ;; |
14 | ;; Version 2, June 1991 ;; |
15 | ;; ;; |
15 | ;; ;; |
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 17... | Line 17... | ||
17 | 17 | ||
Line 18... | Line 18... | ||
18 | $Revision: 3725 $ |
18 | $Revision: 3908 $ |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | struct SOCKET |
20 | struct SOCKET |
Line 752... | Line 752... | ||
752 | get_from_queue (eax + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .block |
752 | get_from_queue (eax + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .block |
Line 753... | Line 753... | ||
753 | 753 | ||
754 | ; Ok, we got a socket ptr |
754 | ; Ok, we got a socket ptr |
Line 755... | Line -... | ||
755 | mov eax, [esi] |
- | |
756 | - | ||
757 | ; Convert it to a socket number |
- | |
758 | call SOCKET_ptr_to_num |
- | |
759 | jz .invalid ; FIXME ? |
755 | mov eax, [esi] |
760 | 756 | ||
761 | ; Change thread ID to that of the current thread |
757 | ; Change thread ID to that of the current thread |
762 | mov ebx, [TASK_BASE] |
758 | mov ebx, [TASK_BASE] |
Line -... | Line 759... | ||
- | 759 | mov ebx, [ebx + TASKDATA.pid] |
|
- | 760 | mov [eax + SOCKET.TID], ebx |
|
- | 761 | ||
- | 762 | ; Convert it to a socket number |
|
763 | mov ebx, [ebx + TASKDATA.pid] |
763 | call SOCKET_ptr_to_num |
764 | mov [eax + SOCKET.TID], ebx |
764 | jz .invalid ; FIXME ? |
765 | 765 | ||
Line 766... | Line 766... | ||
766 | ; and return it to caller |
766 | ; and return it to caller |
Line 869... | Line 869... | ||
869 | jne .return |
869 | jne .return |
Line 870... | Line 870... | ||
870 | 870 | ||
871 | test edi, MSG_DONTWAIT |
871 | test edi, MSG_DONTWAIT |
Line -... | Line 872... | ||
- | 872 | jnz .return_err |
|
- | 873 | ||
- | 874 | test [eax + SOCKET.state], SS_CANTRCVMORE |
|
872 | jnz .return_err |
875 | jnz .return_err |
873 | 876 | ||
Line 874... | Line 877... | ||
874 | ; test [eax + SOCKET.options], SO_NONBLOCK |
877 | ; test [eax + SOCKET.options], SO_NONBLOCK |
875 | ; jnz .return_err |
878 | ; jnz .return_err |
Line 924... | Line 927... | ||
924 | test ecx, ecx |
927 | test ecx, ecx |
925 | jz .nd |
928 | jz .nd |
926 | rep movsd |
929 | rep movsd |
927 | .nd: |
930 | .nd: |
Line 928... | Line 931... | ||
928 | 931 | ||
929 | call kernel_free ; free kernel buffer |
932 | call NET_packet_free |
930 | pop eax ; return number of bytes copied to application |
933 | pop eax ; return number of bytes copied to application |
931 | xor ebx, ebx |
934 | xor ebx, ebx |
Line 932... | Line 935... | ||
932 | ret |
935 | ret |
Line 1563... | Line 1566... | ||
1563 | pusha |
1566 | pusha |
1564 | lea ecx, [eax + SOCKET.mutex] |
1567 | lea ecx, [eax + SOCKET.mutex] |
1565 | call mutex_unlock |
1568 | call mutex_unlock |
1566 | popa |
1569 | popa |
Line 1567... | Line 1570... | ||
1567 | 1570 | ||
1568 | call kernel_free |
1571 | call NET_packet_free |
Line 1569... | Line 1572... | ||
1569 | add esp, 8 |
1572 | add esp, 8 |
Line 1889... | Line 1892... | ||
1889 | 1892 | ||
1890 | .found_pid: |
1893 | .found_pid: |
1891 | shl ecx, 8 |
1894 | shl ecx, 8 |
Line 1892... | Line 1895... | ||
1892 | or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK |
1895 | or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK |
1893 | - | ||
1894 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Raised a network event!\n" |
1896 | |
Line 1895... | Line 1897... | ||
1895 | 1897 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", eax |
|
1896 | jmp .done |
1898 | jmp .done |
1897 | 1899 | ||
Line 2047... | Line 2049... | ||
2047 | ;---------------------------------------------------- |
2049 | ;---------------------------------------------------- |
2048 | ; |
2050 | ; |
2049 | ; SOCKET_free |
2051 | ; SOCKET_free |
2050 | ; |
2052 | ; |
2051 | ; Free socket data memory and remove socket from the list |
2053 | ; Free socket data memory and remove socket from the list |
- | 2054 | ; Caller should lock and unlock socket_mutex |
|
2052 | ; |
2055 | ; |
2053 | ; IN: eax = socket ptr |
2056 | ; IN: eax = socket ptr |
2054 | ; OUT: / |
2057 | ; OUT: / |
2055 | ; |
2058 | ; |
2056 | ;---------------------------------------------------- |
2059 | ;---------------------------------------------------- |
2057 | align 4 |
2060 | align 4 |
2058 | SOCKET_free: |
2061 | SOCKET_free: |
Line 2059... | Line 2062... | ||
2059 | 2062 | ||
Line 2060... | Line -... | ||
2060 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: %x\n", eax |
- | |
2061 | - | ||
2062 | pusha |
- | |
2063 | mov ecx, socket_mutex |
- | |
2064 | call mutex_lock |
- | |
2065 | popa |
2063 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: %x\n", eax |
2066 | 2064 | ||
Line 2067... | Line 2065... | ||
2067 | call SOCKET_check |
2065 | call SOCKET_check |
Line 2107... | Line 2105... | ||
2107 | pop ebx |
2105 | pop ebx |
Line 2108... | Line 2106... | ||
2108 | 2106 | ||
Line 2109... | Line 2107... | ||
2109 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: success!\n" |
2107 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: success!\n" |
2110 | - | ||
2111 | .error: |
- | |
2112 | - | ||
2113 | pusha |
- | |
2114 | mov ecx, socket_mutex |
- | |
2115 | call mutex_unlock |
- | |
2116 | popa |
2108 | |
Line 2117... | Line 2109... | ||
2117 | 2109 | .error: |
|
2118 | ret |
2110 | ret |
2119 | 2111 | ||
Line 2147... | Line 2139... | ||
2147 | mov esi, esp |
2139 | mov esi, esp |
2148 | add_to_queue (ebx + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .fail2 |
2140 | add_to_queue (ebx + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .fail2 |
2149 | pop eax |
2141 | pop eax |
Line 2150... | Line 2142... | ||
2150 | 2142 | ||
2151 | ; Copy structure from current socket to new |
2143 | ; Copy structure from current socket to new |
- | 2144 | ; We start at PID to preserve the socket num, 2 pointers and mutex |
|
2152 | ; We start at PID to preserve the socket num, and the 2 pointers at beginning of socket |
2145 | ; TID will be filled in later |
2153 | lea esi, [ebx + SOCKET.PID] |
2146 | lea esi, [ebx + SOCKET.PID] |
2154 | lea edi, [eax + SOCKET.PID] |
2147 | lea edi, [eax + SOCKET.PID] |
2155 | mov ecx, (SOCKET_QUEUE_LOCATION - SOCKET.PID + 3)/4 |
2148 | mov ecx, (SOCKET_QUEUE_LOCATION - SOCKET.PID + 3)/4 |
Line 2156... | Line 2149... | ||
2156 | rep movsd |
2149 | rep movsd |
Line -... | Line 2150... | ||
- | 2150 | ||
- | 2151 | and [eax + SOCKET.options], not SO_ACCEPTCON |
|
- | 2152 | ||
- | 2153 | ; Notify owner of parent socket |
|
- | 2154 | push eax |
|
- | 2155 | mov eax, ebx |
|
2157 | 2156 | call SOCKET_notify |
|
Line 2158... | Line 2157... | ||
2158 | and [eax + SOCKET.options], not SO_ACCEPTCON |
2157 | pop eax |
2159 | 2158 | ||
2160 | ret |
2159 | ret |
Line 2320... | Line 2319... | ||
2320 | ; |
2319 | ; |
2321 | ;------------------------------------------------------ |
2320 | ;------------------------------------------------------ |
2322 | align 4 |
2321 | align 4 |
2323 | SOCKET_process_end: |
2322 | SOCKET_process_end: |
Line 2324... | Line -... | ||
2324 | - | ||
2325 | pushf |
- | |
2326 | cli ; FIXME |
- | |
2327 | 2323 | ||
Line 2328... | Line 2324... | ||
2328 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_process_end: %x\n", edx |
2324 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_process_end: %x\n", edx |
2329 | 2325 | ||
2330 | pusha |
2326 | pusha |
Line 2349... | Line 2345... | ||
2349 | mov [ebx + SOCKET.PID], 0 |
2345 | mov [ebx + SOCKET.PID], 0 |
2350 | mov eax, ebx |
2346 | mov eax, ebx |
2351 | mov ebx, [ebx + SOCKET.NextPtr] |
2347 | mov ebx, [ebx + SOCKET.NextPtr] |
Line 2352... | Line 2348... | ||
2352 | 2348 | ||
2353 | pusha |
- | |
2354 | mov ecx, socket_mutex |
- | |
2355 | call mutex_unlock |
- | |
2356 | popa |
- | |
2357 | - | ||
2358 | pusha |
2349 | pusha |
2359 | cmp [eax + SOCKET.Domain], AF_INET4 |
2350 | cmp [eax + SOCKET.Domain], AF_INET4 |
Line 2360... | Line 2351... | ||
2360 | jne .free |
2351 | jne .free |
2361 | 2352 | ||
Line 2368... | Line 2359... | ||
2368 | .free: |
2359 | .free: |
2369 | call SOCKET_free |
2360 | call SOCKET_free |
Line 2370... | Line 2361... | ||
2370 | 2361 | ||
2371 | .closed: |
2362 | .closed: |
2372 | popa |
- | |
2373 | - | ||
2374 | pusha |
- | |
2375 | mov ecx, socket_mutex |
- | |
2376 | call mutex_lock |
- | |
2377 | popa |
- | |
2378 | 2363 | popa |
|
Line 2379... | Line 2364... | ||
2379 | jmp .next_socket_test |
2364 | jmp .next_socket_test |
2380 | 2365 | ||
Line 2381... | Line 2366... | ||
2381 | .done: |
2366 | .done: |
2382 | pop ebx |
2367 | pop ebx |
2383 | 2368 | ||
2384 | pusha |
2369 | pusha |
Line 2385... | Line -... | ||
2385 | mov ecx, socket_mutex |
- | |
2386 | call mutex_unlock |
- | |
2387 | popa |
2370 | mov ecx, socket_mutex |