Rev 9049 | Rev 9709 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9049 | Rev 9692 | ||
---|---|---|---|
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: 9049 $ |
18 | $Revision: 9692 $ |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | struct SOCKET |
20 | struct SOCKET |
Line 677... | Line 677... | ||
677 | ; Verify that it is (still) a valid socket |
677 | ; Verify that it is (still) a valid socket |
678 | call socket_check |
678 | call socket_check |
679 | jz .invalid |
679 | jz .invalid |
Line 680... | Line 680... | ||
680 | 680 | ||
681 | ; Change sockets thread owner ID to that of the current thread |
681 | ; Change sockets thread owner ID to that of the current thread |
682 | mov ebx, [TASK_BASE] |
682 | mov ebx, [current_slot] |
683 | mov ebx, [ebx + TASKDATA.pid] |
683 | mov ebx, [ebx + APPDATA.tid] |
Line 684... | Line 684... | ||
684 | mov [eax + SOCKET.TID], ebx |
684 | mov [eax + SOCKET.TID], ebx |
685 | 685 | ||
686 | ; Return socket number to caller |
686 | ; Return socket number to caller |
Line 923... | Line 923... | ||
923 | ; does this socket have a PID yet? |
923 | ; does this socket have a PID yet? |
924 | cmp [eax + SOCKET.PID], 0 |
924 | cmp [eax + SOCKET.PID], 0 |
925 | jne @f |
925 | jne @f |
Line 926... | Line 926... | ||
926 | 926 | ||
927 | ; Change PID to that of current process |
927 | ; Change PID to that of current process |
928 | mov ebx, [TASK_BASE] |
928 | mov ebx, [current_slot] |
929 | mov ebx, [ebx + TASKDATA.pid] |
929 | mov ebx, [ebx + APPDATA.tid] |
930 | mov [eax + SOCKET.PID], ebx |
930 | mov [eax + SOCKET.PID], ebx |
931 | mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( |
931 | mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( |
Line 932... | Line 932... | ||
932 | @@: |
932 | @@: |
Line 1112... | Line 1112... | ||
1112 | ; does this socket have a PID yet? |
1112 | ; does this socket have a PID yet? |
1113 | cmp [eax + SOCKET.PID], 0 |
1113 | cmp [eax + SOCKET.PID], 0 |
1114 | jne @f |
1114 | jne @f |
Line 1115... | Line 1115... | ||
1115 | 1115 | ||
1116 | ; Change PID to that of current process |
1116 | ; Change PID to that of current process |
1117 | mov ebx, [TASK_BASE] |
1117 | mov ebx, [current_slot] |
1118 | mov ebx, [ebx + TASKDATA.pid] |
1118 | mov ebx, [ebx + APPDATA.tid] |
1119 | mov [eax + SOCKET.PID], ebx |
1119 | mov [eax + SOCKET.PID], ebx |
1120 | mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( |
1120 | mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( |
1121 | @@: |
1121 | @@: |
Line 1860... | Line 1860... | ||
1860 | 1860 | ||
1861 | ; Suspend the thread |
1861 | ; Suspend the thread |
1862 | push edx |
1862 | push edx |
1863 | mov edx, [TASK_BASE] |
1863 | mov edx, [TASK_BASE] |
- | 1864 | mov [edx + TASKDATA.state], TSTATE_RUN_SUSPENDED |
|
Line 1864... | Line 1865... | ||
1864 | mov [edx + TASKDATA.state], TSTATE_RUN_SUSPENDED |
1865 | mov edx, [current_slot] |
1865 | 1866 | ||
1866 | ; Remember the thread ID so we can wake it up again |
1867 | ; Remember the thread ID so we can wake it up again |
1867 | mov edx, [edx + TASKDATA.pid] |
1868 | mov edx, [edx + APPDATA.tid] |
1868 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: suspending thread: %u\n", edx |
1869 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: suspending thread: %u\n", edx |
1869 | mov [eax + SOCKET.TID], edx |
1870 | mov [eax + SOCKET.TID], edx |
Line 1900... | Line 1901... | ||
1900 | mov ebx, [eax + SOCKET.TID] |
1901 | mov ebx, [eax + SOCKET.TID] |
1901 | test ebx, ebx |
1902 | test ebx, ebx |
1902 | jz .error2 |
1903 | jz .error2 |
1903 | xor ecx, ecx |
1904 | xor ecx, ecx |
1904 | inc ecx |
1905 | inc ecx |
1905 | mov esi, TASK_DATA |
1906 | ;mov esi, TASK_DATA |
- | 1907 | mov esi, SLOT_BASE + sizeof.APPDATA |
|
1906 | .next: |
1908 | .next: |
1907 | cmp [esi + TASKDATA.pid], ebx |
1909 | ;cmp [esi + TASKDATA.pid], ebx |
- | 1910 | cmp [esi + APPDATA.tid], ebx |
|
1908 | je .found |
1911 | je .found |
1909 | inc ecx |
1912 | inc ecx |
1910 | add esi, sizeof.TASKDATA |
1913 | ;add esi, sizeof.TASKDATA |
- | 1914 | add esi, sizeof.APPDATA |
|
1911 | cmp ecx, [thread_count] |
1915 | cmp ecx, [thread_count] |
1912 | jbe .next |
1916 | jbe .next |
Line 1913... | Line 1917... | ||
1913 | 1917 | ||
1914 | .error2: |
1918 | .error2: |
Line 1925... | Line 1929... | ||
1925 | test [eax + SOCKET.state], SS_BLOCKED |
1929 | test [eax + SOCKET.state], SS_BLOCKED |
1926 | jnz .un_block |
1930 | jnz .un_block |
Line 1927... | Line 1931... | ||
1927 | 1931 | ||
1928 | ; Socket and thread exists and socket is of non blocking type. |
1932 | ; Socket and thread exists and socket is of non blocking type. |
1929 | ; We'll try to flag an event to the thread. |
1933 | ; We'll try to flag an event to the thread. |
1930 | shl ecx, 8 |
1934 | shl ecx, BSF sizeof.APPDATA |
Line 1931... | Line 1935... | ||
1931 | or [SLOT_BASE + ecx + APPDATA.occurred_events], EVENT_NETWORK |
1935 | or [SLOT_BASE + ecx + APPDATA.occurred_events], EVENT_NETWORK |
1932 | 1936 | ||
1933 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", ebx |
1937 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", ebx |
Line 1937... | Line 1941... | ||
1937 | 1941 | ||
1938 | .un_block: |
1942 | .un_block: |
1939 | ; Socket and thread exists and socket is of blocking type |
1943 | ; Socket and thread exists and socket is of blocking type |
1940 | ; We'll try to unblock it. |
1944 | ; We'll try to unblock it. |
- | 1945 | and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag |
|
1941 | and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag |
1946 | shl ecx, BSF sizeof.TASKDATA |
Line 1942... | Line 1947... | ||
1942 | mov [esi + TASKDATA.state], TSTATE_RUNNING ; Run the thread |
1947 | mov [ecx + TASK_TABLE + TASKDATA.state], TSTATE_RUNNING ; Run the thread |
1943 | 1948 | ||
1944 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" |
1949 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" |
Line 2007... | Line 2012... | ||
2007 | mov [last_socket_num], edi |
2012 | mov [last_socket_num], edi |
2008 | mov [eax + SOCKET.Number], edi |
2013 | mov [eax + SOCKET.Number], edi |
2009 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_alloc: number=%u\n", edi |
2014 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_alloc: number=%u\n", edi |
Line 2010... | Line 2015... | ||
2010 | 2015 | ||
2011 | ; Fill in PID |
2016 | ; Fill in PID |
2012 | mov ebx, [TASK_BASE] |
2017 | mov ebx, [current_slot] |
2013 | mov ebx, [ebx + TASKDATA.pid] |
2018 | mov ebx, [ebx + APPDATA.tid] |
2014 | mov [eax + SOCKET.PID], ebx |
2019 | mov [eax + SOCKET.PID], ebx |
Line 2015... | Line 2020... | ||
2015 | mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( |
2020 | mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( |
2016 | 2021 | ||
Line 2321... | Line 2326... | ||
2321 | socket_check_owner: |
2326 | socket_check_owner: |
Line 2322... | Line 2327... | ||
2322 | 2327 | ||
Line 2323... | Line 2328... | ||
2323 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check_owner: %x\n", eax |
2328 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check_owner: %x\n", eax |
2324 | 2329 | ||
2325 | push ebx |
2330 | push ebx |
2326 | mov ebx, [TASK_BASE] |
2331 | mov ebx, [current_slot] |
2327 | mov ebx, [ebx + TASKDATA.pid] |
2332 | mov ebx, [ebx + APPDATA.tid] |
Line 2328... | Line 2333... | ||
2328 | cmp [eax + SOCKET.PID], ebx |
2333 | cmp [eax + SOCKET.PID], ebx |