Subversion Repositories Kolibri OS

Rev

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

Rev 6907 Rev 6908
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: 6907 $
18
$Revision: 6908 $
Line 19... Line 19...
19
 
19
 
20
struct  SOCKET
20
struct  SOCKET
Line 291... Line 291...
291
;                                                                 ;
291
;                                                                 ;
292
;-----------------------------------------------------------------;
292
;-----------------------------------------------------------------;
293
align 4
293
align 4
294
socket_open:
294
socket_open:
Line 295... Line 295...
295
 
295
 
Line 296... Line 296...
296
        DEBUGF  1, "SOCKET_open: domain=%u type=%u protocol=%x\n ", ecx, edx, esi
296
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi
297
 
297
 
298
        push    ecx edx esi
298
        push    ecx edx esi
299
        call    socket_alloc
299
        call    socket_alloc
Line 690... Line 690...
690
        ret
690
        ret
Line 691... Line 691...
691
 
691
 
692
  .block:
692
  .block:
693
        test    [eax + SOCKET.options], SO_NONBLOCK
693
        test    [eax + SOCKET.options], SO_NONBLOCK
694
        jnz     .wouldblock
-
 
-
 
694
        jnz     .wouldblock
695
        DEBUGF  1, "Calling socket_block at 695\n"
695
 
696
        call    socket_block
696
        call    socket_block
Line 697... Line 697...
697
        jmp     .loop
697
        jmp     .loop
698
 
698
 
Line 728... Line 728...
728
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_close: socknum=%u\n", ecx
728
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_close: socknum=%u\n", ecx
Line 729... Line 729...
729
 
729
 
730
        call    socket_num_to_ptr
730
        call    socket_num_to_ptr
731
        test    eax, eax
731
        test    eax, eax
732
        jz      .invalid
-
 
Line 733... Line 732...
733
        DEBUGF  1, "SOCKET_close: socknum=%x\n", eax
732
        jz      .invalid
Line 734... Line 733...
734
 
733
 
Line 760... Line 759...
760
  @@:
759
  @@:
761
        ret
760
        ret
Line 762... Line 761...
762
 
761
 
763
 
-
 
764
  .invalid:
762
 
765
        DEBUGF  1, "SOCKET_close: INVALID!\n"
763
  .invalid:
766
        mov     dword[esp+20], EINVAL
764
        mov     dword[esp+20], EINVAL
Line 791... Line 789...
791
        call    socket_num_to_ptr
789
        call    socket_num_to_ptr
792
        test    eax, eax
790
        test    eax, eax
793
        jz      .invalid
791
        jz      .invalid
Line 794... Line 792...
794
 
792
 
795
  .loop:
-
 
796
        pushf
-
 
797
        cli
793
  .loop:
798
        push    edi
794
        push    edi
799
        call    [eax + SOCKET.rcv_proc]
795
        call    [eax + SOCKET.rcv_proc]
Line 800... Line 796...
800
        pop     edi
796
        pop     edi
Line 808... Line 804...
808
        test    edi, MSG_DONTWAIT
804
        test    edi, MSG_DONTWAIT
809
        jnz     .return_err
805
        jnz     .return_err
Line 810... Line 806...
810
 
806
 
811
        test    [eax + SOCKET.options], SO_NONBLOCK
807
        test    [eax + SOCKET.options], SO_NONBLOCK
812
        jnz     .return_err
-
 
-
 
808
        jnz     .return_err
813
        DEBUGF  1, "Calling socket_block at 813\n"
809
 
814
        call    socket_block
-
 
815
        popf
810
        call    socket_block
Line 816... Line 811...
816
        jmp     .loop
811
        jmp     .loop
817
 
812
 
818
 
813
 
819
  .invalid:
814
  .invalid:
820
        push    EINVAL
815
        push    EINVAL
821
        pop     ebx
816
        pop     ebx
822
  .return_err:
-
 
823
        mov     ecx, -1
817
  .return_err:
824
  .return:
818
        mov     ecx, -1
825
        popf
819
  .return:
Line 826... Line 820...
826
        mov     [esp+20], ebx
820
        mov     [esp+20], ebx
Line 1829... Line 1823...
1829
;                                                                 ;
1823
;                                                                 ;
1830
;-----------------------------------------------------------------;
1824
;-----------------------------------------------------------------;
1831
align 4
1825
align 4
1832
socket_block:
1826
socket_block:
Line 1833... Line 1827...
1833
 
1827
 
Line 1834... Line 1828...
1834
        DEBUGF  1, "SOCKET_block: %x\n", eax
1828
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax
Line 1835... Line 1829...
1835
 
1829
 
1836
        push    eax
1830
        push    eax
Line 1854... Line 1848...
1854
        popf
1848
        popf
Line 1855... Line 1849...
1855
 
1849
 
1856
        call    change_task
1850
        call    change_task
Line 1857... Line 1851...
1857
        pop     eax
1851
        pop     eax
Line 1858... Line 1852...
1858
 
1852
 
Line 1859... Line 1853...
1859
        DEBUGF  1, "SOCKET_block: continuing: %x\n", eax
1853
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_block: continuing\n"
Line 1922... Line 1916...
1922
; Socket and thread exists and socket is of blocking type
1916
; Socket and thread exists and socket is of blocking type
1923
; We'll try to unblock it.
1917
; We'll try to unblock it.
1924
        and     [eax + SOCKET.state], not SS_BLOCKED    ; Clear the 'socket is blocked' flag
1918
        and     [eax + SOCKET.state], not SS_BLOCKED    ; Clear the 'socket is blocked' flag
1925
        mov     [esi + TASKDATA.state], 0               ; Run the thread
1919
        mov     [esi + TASKDATA.state], 0               ; Run the thread
Line 1926... Line 1920...
1926
 
1920
 
1927
        DEBUGF  1, "SOCKET_notify: Unblocked socket!\n"
1921
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
1928
        pop     esi ecx ebx
1922
        pop     esi ecx ebx
Line 1929... Line 1923...
1929
        ret
1923
        ret