SoupMessage unref



Hello,

Im currently using libsoup as a server. I have the following problem.
When using chunked encoding data doesn't get out unless I return from
call back which brings me to another problem that when I return from
the callback SoupMessage is deleted. The only way I have found it to
work if I use the wrote_chunk signal but for big files I find this
slower than doing all in one single callback. Is there a way for the
server not to delete SoupMessage.

Here is my code:



void main()
{
    init();
    http = soup_server_new(SOUP_SERVER_PORT, 9001, NULL);

    soup_server_add_handler(http, "/xyz", xyz_callback, NULL, NULL);
    soup_server_run(http);
}

void
xyz_callback(SoupServer * server, SoupMessage * msg, const char *path,
      GHashTable * query, SoupClientContext * client,
      gpointer user_data)
{


    soup_message_set_status(msg, 200);
    soup_message_headers_set_encoding(msg->response_headers,
     SOUP_ENCODING_CHUNKED);
    soup_message_headers_set_content_type(msg->response_headers,
 "video/webm", NULL);
    soup_message_body_set_accumulate(msg->response_body, FALSE);

     g_signal_connect(msg, "finished", G_CALLBACK(finished_cb),
          server);
    g_thread_new ("tx",sendData,msg); //if i block here data won't be sent.

}

gpointer  sendData(gpointer data)
{

  SoupMessage *msg= SOUP_MESSAGE(data);
  while(condition)
  {
   sendDataF(http,msg);
  }
  return NULL;
}



int sendDataF(SoupServer * server, SoupMessage * msg)
{
    guint8* buffer;
    gsize sz;
    SoupBuffer *sbuff;

    ....
   // here buffer gets filled


    sbuff = soup_buffer_new_with_owner(buffer, sz, buffer, free_buff);
    soup_message_body_append_buffer(msg->response_body, sbuff);
    soup_server_unpause_message(server, msg);
    return 1;
}

Regards,

Ivan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]