Commit f0d50ba9 authored by Greg Williams's avatar Greg Williams
Browse files

Patched SSL packet send to bail out upon completion

parent c8335ee4
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -777,14 +777,36 @@ static ssize_t socket_write_ssl(sender *s, tx_info_t *info, SSL *ssl) {
    boxed_msg *box = info->u.write.box;
    uint8_t *msg = box->out_msg;
    size_t msg_size = box->out_msg_size;
    size_t rem = msg_size - info->u.write.sent_size;
    size_t sent_size = info->u.write.sent_size;
    size_t rem = msg_size - sent_size;
    int fd = info->u.write.fd;
    ssize_t written = 0;
    for (;;) {
        BUS_LOG_SNPRINTF(b, 3, LOG_SENDER, b->udata, 64,
            "SSL write %p to %d, %zd bytes (info %d)",
            (void*)&msg[sent_size], fd, rem, info->id);

        ssize_t wrsz = SSL_write(ssl, &msg[info->u.write.sent_size], rem);

        BUS_LOG_SNPRINTF(b, 3, LOG_SENDER, b->udata, 64,
            "SSL wrote %zd bytes to %d (info %d)",
            wrsz, fd, info->id);

        if (wrsz > 0) {
            update_sent(b, s, info, wrsz);

            written += wrsz;
            size_t rem = msg_size - written;
            
            BUS_LOG_SNPRINTF(b, 3, LOG_SENDER, b->udata, 128,
                "SSL has sent %zd w/ %zd bytes remaining to send to %d (info %d)",
                written, rem, fd, info->id);

            if (rem == 0) {
                BUS_LOG_SNPRINTF(b, 3, LOG_SENDER, b->udata, 128,
                    "SSL has sent all data for current packet! (%zd bytes)", written);
                break;
            }
        } else if (wrsz < 0) {
            int reason = SSL_get_error(ssl, wrsz);
            switch (reason) {
@@ -833,7 +855,7 @@ static void update_sent(struct bus *b, sender *s, tx_info_t *info, ssize_t sent)
    size_t rem = msg_size - info->u.write.sent_size;
    
    BUS_LOG_SNPRINTF(b, 5, LOG_SENDER, b->udata, 64,
        "wrote %zd, msg_size %zd (%p)",
        "wrote %zd, msg_size %zu (%p)",
        sent, msg_size, (void*)box->out_msg);
    if (rem == 0) { /* completed! */
        fd_info *fdi = info->u.write.fdi;
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ static const char strKey[] = "GET system test blob";

void setUp(void)
{ LOG_LOCATION;
    SystemTestSetup(&Fixture, 3);
    SystemTestSetup(&Fixture, 5);

    KeyBuffer = ByteBuffer_CreateAndAppendCString(KeyData, sizeof(KeyData), strKey);
    ExpectedKeyBuffer = ByteBuffer_CreateAndAppendCString(ExpectedKeyData, sizeof(ExpectedKeyData), strKey);