~yeban/libmemcached/todo-host.c

« back to all changes in this revision

Viewing changes to example/memcached_light.c

  • Committer: Brian Aker
  • Date: 2011-03-17 21:45:08 UTC
  • Revision ID: brian@tangent.org-20110317214508-ogufz6pusakvcch0
Merge in updates to make sure exit/return is done properly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
    else
181
181
      perror("getaddrinfo()");
182
182
 
183
 
    return 1;
 
183
    return EXIT_FAILURE;
184
184
  }
185
185
 
186
186
  struct linger ling= {0, 0};
343
343
 *
344
344
 * @param argc number of items in the argument vector
345
345
 * @param argv argument vector
346
 
 * @return 0 on success, 1 otherwise
 
346
 * @return EXIT_SUCCESS on success, 1 otherwise
347
347
 */
348
348
int main(int argc, char **argv)
349
349
{
356
356
  if (event_base == NULL)
357
357
  {
358
358
    fprintf(stderr, "Failed to create an instance of libevent\n");
359
 
    return 1;
 
359
    return EXIT_FAILURE;
360
360
  }
361
361
 
362
362
  /*
389
389
    default:
390
390
      (void)fprintf(stderr, "Usage: %s [-p port] [-v] [-1] [-c #clients] [-P pidfile]\n",
391
391
                    argv[0]);
392
 
      return 1;
 
392
      return EXIT_FAILURE;
393
393
    }
394
394
  }
395
395
 
396
396
  if (! initialize_storage())
397
397
  {
398
398
    /* Error message already printed */
399
 
    return 1;
 
399
    return EXIT_FAILURE;
400
400
  }
401
401
 
402
402
  if (! global_options.has_port)
423
423
  if (num_server_sockets == 0)
424
424
  {
425
425
    fprintf(stderr, "I don't have any server sockets\n");
426
 
    return 1;
 
426
    return EXIT_FAILURE;
427
427
  }
428
428
 
429
429
  /*
439
439
  if ((protocol_handle= memcached_protocol_create_instance()) == NULL)
440
440
  {
441
441
    fprintf(stderr, "Failed to allocate protocol handle\n");
442
 
    return 1;
 
442
    return EXIT_FAILURE;
443
443
  }
444
444
 
445
445
  socket_userdata_map= calloc((size_t)(maxconns), sizeof(struct connection));
446
446
  if (socket_userdata_map == NULL)
447
447
  {
448
448
    fprintf(stderr, "Failed to allocate room for connections\n");
449
 
    return 1;
 
449
    return EXIT_FAILURE;
450
450
  }
451
451
 
452
452
  memcached_binary_protocol_set_callbacks(protocol_handle, interface);
470
470
  event_base_loop(event_base, 0);
471
471
 
472
472
  /* NOTREACHED */
473
 
  return 0;
 
473
  return EXIT_SUCCESS;
474
474
}