Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2994 → Rev 2993

/kernel/branches/net/network/socket.inc
228,26 → 228,6
 
;-----------------------------------------------------------------
;
; SOCKET_block
;
;-----------------------------------------------------------------
macro SOCKET_block socket, loop, done {
 
test [socket + SOCKET.options], SO_BLOCK ; Is this a blocking socket?
jz done ; No, return immediately
 
push esi
mov esi, 5 ; yes, wait for event
call delay_ms
pop esi
 
jmp loop
 
}
 
 
;-----------------------------------------------------------------
;
; Socket API (function 74)
;
;-----------------------------------------------------------------
584,8 → 564,6
mov eax, ebx
call TCP_output
 
;;; TODO: wait for successfull connection if blocking socket
 
mov dword [esp+32], 0
ret
 
688,10 → 666,7
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
jne s_error
 
.loop:
get_from_queue (eax + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .block
 
; Ok, we got a socket ptr
get_from_queue (eax + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, s_error
mov eax, [esi]
 
; Change PID to that of the current process
699,15 → 674,11
mov ebx, [ebx + TASKDATA.pid]
mov [eax + SOCKET.PID], ebx
 
; Convert it to a socket number
call SOCKET_ptr_to_num
jz s_error
; and return it to caller
mov [esp+32], eax
ret
 
.block:
SOCKET_block eax, .loop, s_error
 
;-----------------------------------------------------------------
;
748,8 → 719,6
 
call TCP_usrclosed
call TCP_output ;;;; Fixme: is this nescessary??
 
;;; TODO: wait for successfull termination if blocking socket
mov dword [esp+32], 0
 
ret
791,8 → 760,7
mov ebx, esi
mov edi, edx ; addr to buffer
 
.loop:
get_from_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, .block ; destroys esi and ecx
get_from_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, s_error ; destroys esi and ecx
 
mov ecx, [esi + socket_queue_entry.data_size]
DEBUGF 1,"SOCKET_receive: %u bytes data\n", ecx
827,10 → 795,6
DEBUGF 1,"SOCKET_receive: Buffer too small\n"
jmp s_error
 
.block:
SOCKET_block eax, .loop, s_error
 
 
align 4
SOCKET_receive_tcp:
 
838,21 → 802,16
 
mov ecx, esi
mov edi, edx
add eax, STREAM_SOCKET.rcv
xor edx, edx
add eax, STREAM_SOCKET.rcv
.loop: ;;;; FIXME: ecx!
call SOCKET_ring_read
test ecx, ecx
jz .block
call SOCKET_ring_free
 
mov [esp+32], ecx ; return number of bytes copied
 
ret
 
.block:
SOCKET_block (eax - STREAM_SOCKET.rcv), .loop, s_error
 
 
;-----------------------------------------------------------------
;
; SOCKET_send
1349,13 → 1308,9
; IN: eax = ring struct ptr
; ecx = bytes to read
; edx = offset
; edi = ptr to buffer start
; edi = ptr to buffer
;
; OUT: eax = unchanged
; ecx = number of bytes read (0 on error)
; edx = destroyed
; esi = destroyed
; edi = ptr to buffer end
; OUT: ecx = number of bytes read (0 on error)
;
;-----------------------------------------------------------------
align 4
/kernel/branches/net/network/stack.inc
80,8 → 80,6
SO_USELOOPBACK = 1 shl 8
SO_BINDTODEVICE = 1 shl 9
 
SO_BLOCK = 1 shl 10
 
; Socket level
SOL_SOCKET = 0