Files
@ f6e991030a70
Branch filter:
Location: DistRen/src/client/libdistren.c - annotation
f6e991030a70
3.0 KiB
text/plain
tabletennis_del_client() actually deletes the client if it's not at the front of one of the PING or PONG queues (fixing a segfault).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 9d601d5c27c7 abcf8952747b 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 92659c5651ef da79b5082151 7c0e60f07a51 da79b5082151 7c0e60f07a51 92659c5651ef 2c0ae3006fa0 9d601d5c27c7 b647e12afd51 92659c5651ef da79b5082151 9d601d5c27c7 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 da79b5082151 51bd2f4a1651 da79b5082151 b647e12afd51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 da79b5082151 da79b5082151 da79b5082151 da79b5082151 b647e12afd51 b647e12afd51 b647e12afd51 da79b5082151 52937ad805ae 52937ad805ae 52937ad805ae 52937ad805ae 52937ad805ae 7c0e60f07a51 52937ad805ae 52937ad805ae da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 da79b5082151 7c0e60f07a51 da79b5082151 da79b5082151 da79b5082151 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 b647e12afd51 9d601d5c27c7 9d601d5c27c7 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 7c0e60f07a51 9d601d5c27c7 da79b5082151 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 c21ed954efe5 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 9d601d5c27c7 da79b5082151 da79b5082151 d1ba36f30e32 b647e12afd51 9d601d5c27c7 | /*
Copyright 2010 Nathan Phillip Brink, Ethan Zonca, Matt Orlando
This file is a part of DistRen.
DistRen is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DistRen is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with DistRen. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Implementation of distren_* functions from distren.h excluding distren_job_* functions.
*/
#include "common/config.h"
#include "common/options.h"
#include "common/protocol.h"
#include "common/remoteio.h"
#include "common/request.h"
#include "libdistren.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/**
* Handle common cleanup actions for distren_init().
*/
static void distren_init_cleanup(distren_t distren);
int distren_init(distren_t *handle)
{
int tmp;
struct distren_request *req;
void *data;
if(!handle)
return 1;
*handle = malloc(sizeof(struct distren));
if(!*handle)
return 1;
memset(*handle, 0, sizeof(struct distren));
/* now the environment is ready for general use */
if(_distren_getoptions(*handle))
{
fprintf(stderr, "error getting configuration\n");
distren_init_cleanup(*handle);
return 1;
}
tmp = remoteio_open_server(&(*handle)->rem,
(*handle)->options->remoteio,
(remoteio_read_handle_func_t)&libdistren_remoteio_read_handle,
*handle,
(remoteio_close_handle_func_t)&libdistren_remoteio_close_handle,
(*handle)->server);
if(tmp)
{
fprintf(stderr, "error: unable to connect to server\n");
distren_init_cleanup(*handle);
return 1;
}
/* send off a DISTREN_REQUEST_VERSION to the server */
tmp = distren_request_version(&req, &data, DISTREN_SERVERTYPE_CLIENT, PACKAGE_STRING);
if(tmp)
{
fprintf(stderr, "error: unable to allocate request");
distren_init_cleanup(*handle);
return 1;
}
distren_request_send((*handle)->rem, req, data);
distren_request_free_with_data(req, data);
while((*handle)->rem
&& (*handle)->state == DISTREN_STATE_VERSION)
multiio_poll((*handle)->multiio, 500);
if(!(*handle)->rem)
{
distren_init_cleanup(*handle);
return 1;
}
return 0;
}
static void distren_init_cleanup(distren_t distren)
{
if(distren->rem)
remoteio_close(distren->rem);
distren->rem = NULL;
distren_free(distren);
}
/**
* @todo Stub
*/
int distren_submit_file(distren_t handle, distren_job_t *job, const char *filename)
{
return 1;
}
int distren_free(distren_t handle)
{
if(handle->rem)
remoteio_close(handle->rem);
free(handle);
return 0;
}
|