mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
fixed partial write error
git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@94 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
parent
dbadc630ae
commit
a194849b9e
33
ssl/tls1.c
33
ssl/tls1.c
@ -918,7 +918,8 @@ static int send_raw_packet(SSL *ssl, uint8_t protocol)
|
|||||||
{
|
{
|
||||||
uint8_t *rec_buf = ssl->bm_all_data;
|
uint8_t *rec_buf = ssl->bm_all_data;
|
||||||
int pkt_size = SSL_RECORD_SIZE+ssl->bm_index;
|
int pkt_size = SSL_RECORD_SIZE+ssl->bm_index;
|
||||||
int ret;
|
int sent = 0;
|
||||||
|
int ret = SSL_OK;
|
||||||
|
|
||||||
rec_buf[0] = protocol;
|
rec_buf[0] = protocol;
|
||||||
rec_buf[1] = 0x03; /* version = 3.1 (TLS) */
|
rec_buf[1] = 0x03; /* version = 3.1 (TLS) */
|
||||||
@ -927,11 +928,33 @@ static int send_raw_packet(SSL *ssl, uint8_t protocol)
|
|||||||
rec_buf[4] = ssl->bm_index & 0xff;
|
rec_buf[4] = ssl->bm_index & 0xff;
|
||||||
|
|
||||||
DISPLAY_BYTES(ssl, "sending %d bytes", ssl->bm_all_data,
|
DISPLAY_BYTES(ssl, "sending %d bytes", ssl->bm_all_data,
|
||||||
pkt_size, pkt_size);
|
pkt_size, pkt_size);
|
||||||
|
|
||||||
if ((ret = SOCKET_WRITE(ssl->client_fd,
|
while (sent < pkt_size)
|
||||||
ssl->bm_all_data, pkt_size)) < 0)
|
{
|
||||||
ret = SSL_ERROR_CONN_LOST;
|
if ((ret = SOCKET_WRITE(ssl->client_fd,
|
||||||
|
&ssl->bm_all_data[sent], pkt_size)) < 0)
|
||||||
|
{
|
||||||
|
ret = SSL_ERROR_CONN_LOST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sent += ret;
|
||||||
|
|
||||||
|
/* keep going until the write buffer has some space */
|
||||||
|
if (sent != pkt_size)
|
||||||
|
{
|
||||||
|
fd_set wfds;
|
||||||
|
FD_ZERO(&wfds);
|
||||||
|
FD_SET(ssl->client_fd, &wfds);
|
||||||
|
|
||||||
|
if (select(ssl->client_fd + 1, NULL, &wfds, NULL, NULL) < 0)
|
||||||
|
{
|
||||||
|
ret = SSL_ERROR_CONN_LOST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SET_SSL_FLAG(SSL_NEED_RECORD); /* reset for next time */
|
SET_SSL_FLAG(SSL_NEED_RECORD); /* reset for next time */
|
||||||
ssl->bm_index = 0;
|
ssl->bm_index = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user