[gnet] gnet is slooow in receiving data



Hello,

I've written a simple multithreaded server application for inhouse use.
This server accepts connections, asks for user and password a la
the POP-3 protocol, and accepts an XML data file for upload.

I used the following pseudocode:

gnet_inetaddr_set_port()
gnet_server_new( .. ob_server_func .. )
g_main_run(..)

static void ob_server_func() {
...
    case GNET_SERVER_STATUS_CONNECT:
      {
        if (debug) {
          LOG(LOG_DEBUG, "New connection from %s", gnet_inetaddr_get_canonical_name(conn->inetaddr));
        }
        conn->func = ob_client_func;
        conn->user_data = calloc(1, sizeof(struct conn_stat));
        gnet_conn_write (conn, strdup(hello), strlen(hello), 0);
        gnet_conn_readline (conn, NULL, 1024, 30000);
        break;
      }


ob_client_func(..)
  switch (status) {
    case GNET_CONN_STATUS_READ:
      {
       readline, save to file....


Everything works fine, but performance is really terrible, even a
256KB file takes a full minute, while CPU load goes to 100%.

If I connect an strace to the server I see:

read(7, "t", 1)                         = 1
gettimeofday({1037278727, 452872}, NULL) = 0
gettimeofday({1037278727, 452956}, NULL) = 0
poll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN, revents=POLLIN}], 4, 8688) = 1
gettimeofday({1037278727, 453147}, NULL) = 0
read(7, "e", 1)

which means the input is read byte-for-byte from the network.
Is this normal behaviour?

Am I doing something wrong here?

I am using GNet 1.1.7 with Glib 2.0.6

Thanks,
Ron Arts

--
Netland Internet Services
bedrijfsmatige internetoplossingen

http://www.netland.nl   Kruislaan 419              1098 VA Amsterdam
info: 020-5628282       servicedesk: 020-5628280   fax: 020-5628281

NETWORK: What fishermen do when not fishing.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



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