OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/socket/ssl_server_socket_nss.h" | 5 #include "net/socket/ssl_server_socket_nss.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 char *buf; | 521 char *buf; |
522 memio_GetReadParams(nss_bufs_, &buf); | 522 memio_GetReadParams(nss_bufs_, &buf); |
523 memcpy(buf, recv_buffer_->data(), result); | 523 memcpy(buf, recv_buffer_->data(), result); |
524 } | 524 } |
525 recv_buffer_ = NULL; | 525 recv_buffer_ = NULL; |
526 memio_PutReadResult(nss_bufs_, MapErrorToNSS(result)); | 526 memio_PutReadResult(nss_bufs_, MapErrorToNSS(result)); |
527 transport_recv_busy_ = false; | 527 transport_recv_busy_ = false; |
528 OnRecvComplete(result); | 528 OnRecvComplete(result); |
529 } | 529 } |
530 | 530 |
531 // Do network I/O between the given buffer and the given socket. | 531 // Do as much network I/O as possible between the buffer and the |
532 // Return true if some I/O performed, false otherwise (error or ERR_IO_PENDING) | 532 // transport socket. Return true if some I/O performed, false |
| 533 // otherwise (error or ERR_IO_PENDING). |
533 bool SSLServerSocketNSS::DoTransportIO() { | 534 bool SSLServerSocketNSS::DoTransportIO() { |
534 bool network_moved = false; | 535 bool network_moved = false; |
535 if (nss_bufs_ != NULL) { | 536 if (nss_bufs_ != NULL) { |
536 int nsent = BufferSend(); | 537 int rv; |
537 int nreceived = BufferRecv(); | 538 // Read and write as much data as we can. The loop is neccessary |
538 network_moved = (nsent > 0 || nreceived >= 0); | 539 // because Write() may return synchronously. |
| 540 do { |
| 541 rv = BufferSend(); |
| 542 if (rv > 0) |
| 543 network_moved = true; |
| 544 } while (rv > 0); |
| 545 if (BufferRecv() >= 0) |
| 546 network_moved = true; |
539 } | 547 } |
540 return network_moved; | 548 return network_moved; |
541 } | 549 } |
542 | 550 |
543 int SSLServerSocketNSS::DoPayloadRead() { | 551 int SSLServerSocketNSS::DoPayloadRead() { |
544 DCHECK(user_read_buf_); | 552 DCHECK(user_read_buf_); |
545 DCHECK_GT(user_read_buf_len_, 0); | 553 DCHECK_GT(user_read_buf_len_, 0); |
546 int rv = PR_Read(nss_fd_, user_read_buf_->data(), user_read_buf_len_); | 554 int rv = PR_Read(nss_fd_, user_read_buf_->data(), user_read_buf_len_); |
547 if (rv >= 0) | 555 if (rv >= 0) |
548 return rv; | 556 return rv; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop | 749 // We must call EnsureOCSPInit() here, on the IO thread, to get the IO loop |
742 // by MessageLoopForIO::current(). | 750 // by MessageLoopForIO::current(). |
743 // X509Certificate::Verify() runs on a worker thread of CertVerifier. | 751 // X509Certificate::Verify() runs on a worker thread of CertVerifier. |
744 EnsureOCSPInit(); | 752 EnsureOCSPInit(); |
745 #endif | 753 #endif |
746 | 754 |
747 return OK; | 755 return OK; |
748 } | 756 } |
749 | 757 |
750 } // namespace net | 758 } // namespace net |
OLD | NEW |