pike.git / lib / modules / SSL.pmod / Connection.pike

version» Context lines:

pike.git/lib/modules/SSL.pmod/Connection.pike:598:   //! Returns the number of packets queued for writing.   //!   //! @returns   //! Returns the number of times @[to_write()] can be called before   //! it stops returning non-empty strings.   int query_write_queue_size()   {    return sizeof(alert_q) + sizeof(urgent_q) + sizeof(application_q);   }    - //! Extracts data from the packet queues. Returns a string of data - //! to be written, 0 if there are no pending packets, 1 of the - //! connection is being closed politely, and -1 if the connection - //! died unexpectedly. + //! Extracts data from the packet queues. Returns 2 if data has been + //! written, 0 if there are no pending packets, 1 of the connection is + //! being closed politely, and -1 if the connection died unexpectedly.   //!   //! This function is intended to be called from an i/o write callback.   //!   //! @seealso   //! @[query_write_queue_size()], @[send_streaming_data()]. - string|int to_write() + int(-1..2) to_write(Stdio.Buffer output)   {    if (state & CONNECTION_local_fatal)    return -1;       Packet packet = [object(Packet)](alert_q->get() || urgent_q->get() ||    application_q->get());    if (!packet)    return !!(state & CONNECTION_local_closing);       SSL3_DEBUG_MSG("SSL.Connection: writing packet of type %d, %O\n",
pike.git/lib/modules/SSL.pmod/Connection.pike:647:    packet = current_write_state->encrypt_packet(packet, context);    if (packet->content_type == PACKET_change_cipher_spec) {    if (sizeof(pending_write_state)) {    current_write_state = pending_write_state[0];    pending_write_state = pending_write_state[1..];    } else {    error("Invalid Change Cipher Spec.\n");    }    if (version >= PROTOCOL_TLS_1_3) {    // The change cipher state packet is not sent on the wire in TLS 1.3. -  return to_write(); +  return 2;    }    }    -  return packet->send(); +  packet->send(output); +  return 2;   }      //! Initiate close.   void send_close()   {    send_packet(alert(ALERT_warning, ALERT_close_notify,    "Closing connection.\n"), PRI_application);   }      //! Renegotiate the connection.