Subversion Repositories Kolibri OS

Rev

Rev 4520 | Rev 4528 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4520 Rev 4527
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org,                           ;;
8
;;   Written by hidnplayr@kolibrios.org,                           ;;
Line 1751... Line 1751...
1751
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: %x\n", eax
1751
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: %x\n", eax
Line 1752... Line 1752...
1752
 
1752
 
1753
        call    SOCKET_check
1753
        call    SOCKET_check
Line 1754... Line -...
1754
        jz      .error
-
 
1755
 
-
 
1756
        test    [eax + SOCKET.state], SS_BLOCKED
-
 
1757
        jnz     .unblock
-
 
1758
 
-
 
1759
;        test    [eax + SOCKET.options], SO_NONBLOCK
-
 
1760
;        jz      .error
-
 
1761
 
-
 
1762
        push    eax ecx esi
-
 
1763
 
-
 
1764
; socket exists and is of non blocking type.
-
 
1765
; We'll try to flag an event to the thread
-
 
1766
 
-
 
1767
        mov     eax, [eax + SOCKET.TID]
-
 
1768
        test    eax, eax
-
 
1769
        jz      .done
1754
        jz      .error
1770
        mov     ecx, 1
-
 
1771
        mov     esi, TASK_DATA + TASKDATA.pid
-
 
1772
 
-
 
1773
  .next_pid:
-
 
1774
        cmp     [esi], eax
-
 
1775
        je      .found_pid
-
 
1776
        inc     ecx
-
 
1777
        add     esi, 0x20
-
 
1778
        cmp     ecx, [TASK_COUNT]
-
 
1779
        jbe     .next_pid
-
 
1780
; PID not found, TODO: close socket!
-
 
1781
        jmp     .done
-
 
1782
 
-
 
1783
  .found_pid:
-
 
1784
        shl     ecx, 8
-
 
1785
        or      [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK
-
 
1786
 
-
 
1787
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", eax
-
 
1788
        jmp     .done
-
 
1789
 
1755
 
1790
  .unblock:
-
 
1791
        push    eax ecx esi
-
 
1792
        ; Clear the 'socket is blocked' flag
-
 
1793
        and     [eax + SOCKET.state], not SS_BLOCKED
-
 
1794
 
1756
; Find the associated thread's TASK_DATA
1795
        ; Find the thread's TASK_DATA
1757
        push    ebx ecx esi
1796
        mov     eax, [eax + SOCKET.TID]
1758
        mov     ebx, [eax + SOCKET.TID]
1797
        test    eax, eax
1759
        test    ebx, ebx
1798
        jz      .error
1760
        jz      .error2
1799
        xor     ecx, ecx
1761
        xor     ecx, ecx
1800
        inc     ecx
1762
        inc     ecx
1801
        mov     esi, TASK_DATA
1763
        mov     esi, TASK_DATA
1802
  .next:
1764
  .next:
1803
        cmp     [esi + TASKDATA.pid], eax
1765
        cmp     [esi + TASKDATA.pid], ebx
1804
        je      .found
1766
        je      .found
1805
        inc     ecx
1767
        inc     ecx
1806
        add     esi, 0x20
1768
        add     esi, 0x20
-
 
1769
        cmp     ecx, [TASK_COUNT]
-
 
1770
        jbe     .next
-
 
1771
 
-
 
1772
  .error2:
1807
        cmp     ecx, [TASK_COUNT]
1773
; PID not found, TODO: close socket!
-
 
1774
        DEBUGF  DEBUG_NETWORK_ERROR, "SOCKET_notify: error finding thread 0x%x !\n", ebx
-
 
1775
        pop     esi ecx ebx
-
 
1776
        ret
-
 
1777
 
-
 
1778
  .error:
-
 
1779
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: invalid socket ptr: 0x%x !\n", eax
1808
        jbe     .next
1780
        ret
-
 
1781
 
-
 
1782
  .found:
Line -... Line 1783...
-
 
1783
        test    [eax + SOCKET.state], SS_BLOCKED
1809
        jmp     .error
1784
        jnz     .unblock
1810
  .found:
1785
 
1811
 
1786
; socket and thread exists and socket is of non blocking type.
Line 1812... Line -...
1812
        ; Run the thread
-
 
-
 
1787
; We'll try to flag an event to the thread.
1813
        mov     [esi + TASKDATA.state], 0       ; Running
1788
        shl     ecx, 8
-
 
1789
        or      [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK
Line -... Line 1790...
-
 
1790
 
1814
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
1791
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", eax
-
 
1792
        pop     esi ecx ebx
-
 
1793
        ret
-
 
1794
 
-
 
1795
 
-
 
1796
  .unblock:
-
 
1797
; socket and thread exists and socket is of blocking type
-
 
1798
; We'll try to unblock it.
1815
 
1799
        and     [eax + SOCKET.state], not SS_BLOCKED    ; Clear the 'socket is blocked' flag
Line 1816... Line 1800...
1816
  .done:
1800
        mov     [esi + TASKDATA.state], 0               ; Run the thread
1817
        pop     esi ecx eax
1801