Add bool to determine if socket has been closed.
This commit is contained in:
parent
33b9ab47d9
commit
efca06c71c
2 changed files with 4 additions and 2 deletions
|
|
@ -116,7 +116,7 @@ proc sendStatus(client: PAsyncSocket, status: string): Future[void] =
|
||||||
proc processClient(client: PAsyncSocket, address: string,
|
proc processClient(client: PAsyncSocket, address: string,
|
||||||
callback: proc (request: TRequest):
|
callback: proc (request: TRequest):
|
||||||
Future[void] {.closure, gcsafe.}) {.async.} =
|
Future[void] {.closure, gcsafe.}) {.async.} =
|
||||||
while true:
|
while not client.closed:
|
||||||
# GET /path HTTP/1.1
|
# GET /path HTTP/1.1
|
||||||
# Header: val
|
# Header: val
|
||||||
# \n
|
# \n
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ type
|
||||||
# PAsyncSocket* {.borrow: `.`.} = distinct PSocket. But that doesn't work.
|
# PAsyncSocket* {.borrow: `.`.} = distinct PSocket. But that doesn't work.
|
||||||
AsyncSocketDesc = object
|
AsyncSocketDesc = object
|
||||||
fd*: SocketHandle
|
fd*: SocketHandle
|
||||||
case isBuffered*: bool # determines whether this socket is buffered.
|
closed*: bool ## determines whether this socket has been closed
|
||||||
|
case isBuffered*: bool ## determines whether this socket is buffered.
|
||||||
of true:
|
of true:
|
||||||
buffer*: array[0..BufferSize, char]
|
buffer*: array[0..BufferSize, char]
|
||||||
currPos*: int # current index in buffer
|
currPos*: int # current index in buffer
|
||||||
|
|
@ -400,6 +401,7 @@ proc close*(socket: PAsyncSocket) =
|
||||||
raiseSslError()
|
raiseSslError()
|
||||||
elif res != 1:
|
elif res != 1:
|
||||||
raiseSslError()
|
raiseSslError()
|
||||||
|
socket.closed = true # TODO: Add extra debugging checks for this.
|
||||||
|
|
||||||
when defined(ssl):
|
when defined(ssl):
|
||||||
proc wrapSocket*(ctx: SslContext, socket: AsyncSocket) =
|
proc wrapSocket*(ctx: SslContext, socket: AsyncSocket) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue