Пример #1
0
static jint
outStream_send(PacketOutputStream *stream) {

    jint rc;
    jint len = 0;
    PacketData *segment;
    jbyte *data, *posP;

    /*
     * If there's only 1 segment then we just send the 
     * packet. 
     */
    if (stream->firstSegment.next == NULL) {
        stream->packet.type.cmd.len = 11 + stream->firstSegment.length;
        stream->packet.type.cmd.data = stream->firstSegment.data;
        rc = transport_sendPacket(&stream->packet);
        return rc;
    }

    /*
     * Multiple segments
     */
    len = 0; 
    segment = (PacketData *)&(stream->firstSegment);
    do {
        len += segment->length;
        segment = segment->next;
    } while (segment != NULL); 

    data = jvmtiAllocate(len);
    if (data == NULL) {
        return JDWP_ERROR(OUT_OF_MEMORY);
    }

    posP = data;
    segment = (PacketData *)&(stream->firstSegment);
    while (segment != NULL) {
        (void)memcpy(posP, segment->data, segment->length);
        posP += segment->length;
        segment = segment->next;
    }

    stream->packet.type.cmd.len = 11 + len;
    stream->packet.type.cmd.data = data;
    rc = transport_sendPacket(&stream->packet);
    stream->packet.type.cmd.data = NULL;
    jvmtiDeallocate(data); 

    return rc;
}
Пример #2
0
void 
outStream_sendCommand(PacketOutputStream *stream)
{
    jint error;
    if (!stream->error) {
        error = transport_sendPacket(&stream->packet);
        if (error == 0) {
            stream->sent = JNI_TRUE;
        }
    } 
}
Пример #3
0
void 
outStream_sendReply(PacketOutputStream *stream)
{
    jint error;
    if (stream->error) {
        /*
         * Don't send any collected stream data on an error reply
         */
        stream->packet.type.reply.data.length = 0;
        stream->packet.type.reply.errorCode = (jshort)stream->error;
    } 
    error = transport_sendPacket(&stream->packet);
    if (error == 0) {
        stream->sent = JNI_TRUE;
    }
}