9
/*___INFO__MARK_BEGIN__*/
10
/*************************************************************************
12
* The Contents of this file are made available subject to the terms of
13
* the Sun Industry Standards Source License Version 1.2
15
* Sun Microsystems Inc., March, 2001
18
* Sun Industry Standards Source License Version 1.2
19
* =================================================
20
* The contents of this file are subject to the Sun Industry Standards
21
* Source License Version 1.2 (the "License"); You may not use this file
22
* except in compliance with the License. You may obtain a copy of the
23
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
25
* Software provided under this License is provided on an "AS IS" basis,
26
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
27
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
28
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
29
* See the License for the specific provisions governing your rights and
30
* obligations concerning the Software.
32
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
34
* Copyright: 2001 by Sun Microsystems, Inc.
36
* All Rights Reserved.
38
************************************************************************/
39
/*___INFO__MARK_END__*/
41
#include "cl_host_list.h"
42
#include "cl_host_alias_list.h"
43
#include "cl_commlib.h"
44
#include "uti/sge_hostname.h"
46
static struct in_addr* cl_com_copy_in_addr(struct in_addr *in_addr);
47
static cl_com_hostent_t* cl_com_copy_hostent(cl_com_hostent_t* hostent);
49
#ifdef __CL_FUNCTION__
50
#undef __CL_FUNCTION__
52
#define __CL_FUNCTION__ "cl_host_list_setup()"
53
int cl_host_list_setup(cl_raw_list_t** list_p,
55
cl_host_resolve_method_t method,
56
char* host_alias_file,
57
char* local_domain_name,
58
unsigned long entry_life_time,
59
unsigned long entry_update_time,
60
unsigned long entry_reresolve_time,
61
cl_bool_t create_hash) {
62
int ret_val = CL_RETVAL_OK;
63
cl_host_list_data_t* ldata = NULL;
65
ldata = (cl_host_list_data_t*) malloc(sizeof(cl_host_list_data_t));
67
return CL_RETVAL_MALLOC;
69
ldata->host_alias_file = NULL;
70
ldata->alias_file_changed = 0;
71
ldata->host_alias_list = NULL;
72
ldata->resolve_method = method;
73
ldata->entry_life_time = entry_life_time;
74
ldata->entry_update_time = entry_update_time;
75
ldata->entry_reresolve_time = entry_reresolve_time;
76
ldata->last_refresh_time = 0;
78
if (local_domain_name == NULL && method == CL_LONG) {
79
CL_LOG(CL_LOG_WARNING,"can't compare short host names without default domain when method is CL_LONG");
83
if (entry_life_time == 0) {
84
unsigned long help_value = 0;
86
help_value = cl_util_get_ulong_value(getenv("SGE_COMMLIB_HOST_LIST_LIFE_TIME"));
88
CL_LOG(CL_LOG_INFO,"environment variable SGE_COMMLIB_HOST_LIST_LIFE_TIME is set");
89
ldata->entry_life_time = help_value;
91
CL_LOG(CL_LOG_INFO,"using default value for entry_life_time");
92
ldata->entry_life_time = CL_HOST_LIST_DEFAULT_LIFE_TIME;
96
if (entry_update_time == 0) {
97
unsigned long help_value = 0;
99
help_value = cl_util_get_ulong_value(getenv("SGE_COMMLIB_HOST_LIST_UPDATE_TIME"));
100
if (help_value > 0) {
101
CL_LOG(CL_LOG_INFO,"environment variable SGE_COMMLIB_HOST_LIST_UPDATE_TIME is set");
102
ldata->entry_update_time = help_value;
104
CL_LOG(CL_LOG_INFO,"using default value for entry_update_time");
105
ldata->entry_update_time = CL_HOST_LIST_DEFAULT_UPDATE_TIME;
109
if (entry_reresolve_time == 0) {
110
unsigned long help_value = 0;
112
help_value = cl_util_get_ulong_value(getenv("SGE_COMMLIB_HOST_LIST_RERESOLVE_TIME"));
113
if (help_value > 0) {
114
CL_LOG(CL_LOG_INFO,"environment variable SGE_COMMLIB_HOST_LIST_RERESOLVE_TIME is set");
115
ldata->entry_reresolve_time = help_value;
117
CL_LOG(CL_LOG_INFO,"using default value for entry_reresolve_time");
118
ldata->entry_reresolve_time = CL_HOST_LIST_DEFAULT_RERESOLVE_TIME;
122
if ( ldata->entry_life_time > CL_HOST_LIST_MAX_LIFE_TIME) {
123
CL_LOG_INT(CL_LOG_WARNING,"entry_life_time exceeds maximum of",CL_HOST_LIST_MAX_LIFE_TIME);
124
CL_LOG(CL_LOG_WARNING,"using default value for entry_life_time");
125
ldata->entry_life_time = CL_HOST_LIST_DEFAULT_LIFE_TIME;
128
if ( ldata->entry_update_time > CL_HOST_LIST_MAX_UPDATE_TIME) {
129
CL_LOG_INT(CL_LOG_WARNING,"entry_update_time exceeds maximum of",CL_HOST_LIST_MAX_UPDATE_TIME);
130
CL_LOG(CL_LOG_WARNING,"using default value for entry_update_time");
131
ldata->entry_update_time = CL_HOST_LIST_DEFAULT_UPDATE_TIME;
134
if ( ldata->entry_reresolve_time > CL_HOST_LIST_MAX_RERESOLVE_TIME) {
135
CL_LOG_INT(CL_LOG_WARNING,"entry_reresolve_time exceeds maximum of",CL_HOST_LIST_MAX_RERESOLVE_TIME);
136
CL_LOG(CL_LOG_WARNING,"using default value for entry_reresolve_time");
137
ldata->entry_reresolve_time = CL_HOST_LIST_DEFAULT_RERESOLVE_TIME;
140
if (ldata->entry_life_time <= ldata->entry_update_time || ldata->entry_life_time <= ldata->entry_reresolve_time) {
142
CL_LOG(CL_LOG_ERROR,"entry_life_time must be >= entry_update_time and >= entry_reresolve_time");
143
cl_commlib_push_application_error(CL_LOG_ERROR, CL_RETVAL_PARAMS, "SGE_COMMLIB_HOST_LIST_LIFE_TIME must be >= SGE_COMMLIB_HOST_LIST_UPDATE_TIME and >= SGE_COMMLIB_HOST_LIST_RERESOLVE_TIME");
144
return CL_RETVAL_PARAMS;
146
if (ldata->entry_update_time <= ldata->entry_reresolve_time) {
148
CL_LOG(CL_LOG_ERROR,"entry_update_time must be >= entry_reresolve_time");
149
cl_commlib_push_application_error(CL_LOG_ERROR, CL_RETVAL_PARAMS, "SGE_COMMLIB_HOST_LIST_UPDATE_TIME must be >= SGE_COMMLIB_HOST_LIST_RERESOLVE_TIME");
150
return CL_RETVAL_PARAMS;
153
ret_val = cl_host_alias_list_setup(&(ldata->host_alias_list), "host alias list");
154
if (ret_val != CL_RETVAL_OK) {
156
CL_LOG(CL_LOG_ERROR,"error setting up host alias list");
160
if (host_alias_file != NULL) {
161
ldata->host_alias_file = strdup(host_alias_file);
162
ldata->alias_file_changed = 1;
163
if (ldata->host_alias_file == NULL) {
165
return CL_RETVAL_MALLOC;
168
ldata->host_alias_file = NULL;
171
if (local_domain_name != NULL) {
172
ldata->local_domain_name = strdup(local_domain_name);
173
if (ldata->local_domain_name == NULL) {
174
if (ldata->host_alias_file != NULL) {
175
free(ldata->host_alias_file);
178
return CL_RETVAL_MALLOC;
181
ldata->local_domain_name = NULL;
186
ret_val = cl_raw_list_setup(list_p,list_name, 1);
187
if (ret_val != CL_RETVAL_OK) {
188
if (ldata->host_alias_file != NULL) {
189
free(ldata->host_alias_file);
191
if (ldata->local_domain_name != NULL) {
192
free(ldata->local_domain_name);
198
switch(ldata->resolve_method) {
200
CL_LOG(CL_LOG_INFO,"using short hostname for host compare operations");
204
CL_LOG(CL_LOG_INFO,"using long hostname for host compare operations");
208
CL_LOG(CL_LOG_WARNING,"undefined resolving method");
212
if (ldata->host_alias_file != NULL) {
213
CL_LOG_STR(CL_LOG_INFO,"using host alias file:", ldata->host_alias_file);
215
CL_LOG(CL_LOG_INFO,"no host alias file specified");
217
if (ldata->local_domain_name != NULL) {
218
CL_LOG_STR(CL_LOG_INFO,"using local domain name:", ldata->local_domain_name);
220
CL_LOG(CL_LOG_INFO,"no local domain specified");
223
/* create hashtable */
224
if (create_hash == CL_TRUE) {
225
ldata->ht = sge_htable_create(4, dup_func_string, hash_func_string, hash_compare_string);
226
if (ldata->ht == NULL) {
227
cl_raw_list_cleanup(list_p);
228
if (ldata->host_alias_file != NULL) {
229
free(ldata->host_alias_file);
231
if (ldata->local_domain_name != NULL) {
232
free(ldata->local_domain_name);
235
return CL_RETVAL_MALLOC;
237
CL_LOG_INT(CL_LOG_INFO,"created hash table with size =", 4);
239
CL_LOG(CL_LOG_INFO,"created NO hash table!");
243
/* set private list data */
244
(*list_p)->list_data = ldata;
246
CL_LOG_INT(CL_LOG_INFO,"entry_life_time is", (int)ldata->entry_life_time);
247
CL_LOG_INT(CL_LOG_INFO,"entry_update_time is", (int)ldata->entry_update_time);
248
CL_LOG_INT(CL_LOG_INFO,"entry_reresolve_time is", (int)ldata->entry_reresolve_time);
253
#ifdef __CL_FUNCTION__
254
#undef __CL_FUNCTION__
256
#define __CL_FUNCTION__ "cl_host_list_copy()"
257
int cl_host_list_copy(cl_raw_list_t** destination, cl_raw_list_t* source, cl_bool_t create_hash) {
258
int ret_val = CL_RETVAL_OK;
259
cl_host_list_data_t* ldata_source = NULL;
260
cl_host_list_data_t* ldata_dest = NULL;
261
cl_host_alias_list_elem_t* alias_elem = NULL;
262
cl_host_list_elem_t* host_elem = NULL;
264
if (source == NULL) {
265
return CL_RETVAL_PARAMS;
268
ret_val = cl_raw_list_lock(source);
269
if (ret_val != CL_RETVAL_OK) {
273
/* create a new host list */
274
ldata_source = (cl_host_list_data_t*) source->list_data;
275
if (ldata_source != NULL) {
276
ret_val = cl_host_list_setup(destination,
278
ldata_source->resolve_method,
279
ldata_source->host_alias_file,
280
ldata_source->local_domain_name,
281
ldata_source->entry_life_time,
282
ldata_source->entry_update_time,
283
ldata_source->entry_reresolve_time,
286
CL_LOG(CL_LOG_ERROR,"not list data specified");
287
ret_val = CL_RETVAL_UNKNOWN;
290
if (ret_val != CL_RETVAL_OK) {
291
cl_raw_list_unlock(source);
292
cl_host_list_cleanup(destination);
296
/* list created, now get private data structures */
297
ldata_dest = (cl_host_list_data_t*) (*destination)->list_data;
299
ldata_dest->alias_file_changed = ldata_source->alias_file_changed;
300
ldata_dest->last_refresh_time = ldata_source->last_refresh_time;
302
/* now copy alias list */
303
cl_raw_list_lock(ldata_source->host_alias_list);
305
alias_elem = cl_host_alias_list_get_first_elem(ldata_source->host_alias_list);
307
ret_val = cl_host_alias_list_append_host(ldata_dest->host_alias_list,
308
alias_elem->local_resolved_hostname,
309
alias_elem->alias_name, 0);
310
if (ret_val != CL_RETVAL_OK) {
311
cl_raw_list_unlock(ldata_source->host_alias_list);
312
cl_raw_list_unlock(source);
313
cl_host_list_cleanup(destination);
316
alias_elem = cl_host_alias_list_get_next_elem(alias_elem);
318
cl_raw_list_unlock(ldata_source->host_alias_list);
320
/* ok, now copy the entries */
321
host_elem = cl_host_list_get_first_elem(source);
323
cl_com_host_spec_t* new_host_spec = NULL;
325
new_host_spec = ( cl_com_host_spec_t*) malloc( sizeof(cl_com_host_spec_t) );
326
if (new_host_spec == NULL) {
327
cl_raw_list_unlock(source);
328
cl_host_list_cleanup(destination);
329
return CL_RETVAL_MALLOC;
332
/* copy host_spec_ type */
333
new_host_spec->resolve_error = host_elem->host_spec->resolve_error;
334
new_host_spec->last_resolve_time = host_elem->host_spec->last_resolve_time;
335
new_host_spec->creation_time = host_elem->host_spec->creation_time;
337
if ( host_elem->host_spec->resolved_name ) {
338
new_host_spec->resolved_name = strdup(host_elem->host_spec->resolved_name);
339
if ( new_host_spec->resolved_name == NULL) {
340
cl_com_free_hostspec(&new_host_spec);
341
cl_raw_list_unlock(source);
342
cl_host_list_cleanup(destination);
343
return CL_RETVAL_MALLOC;
346
new_host_spec->resolved_name = NULL;
349
if ( host_elem->host_spec->unresolved_name ) {
350
new_host_spec->unresolved_name = strdup(host_elem->host_spec->unresolved_name);
351
if ( new_host_spec->unresolved_name == NULL) {
352
cl_com_free_hostspec(&new_host_spec);
353
cl_raw_list_unlock(source);
354
cl_host_list_cleanup(destination);
355
return CL_RETVAL_MALLOC;
358
new_host_spec->unresolved_name = NULL;
361
if ( host_elem->host_spec->in_addr) {
362
new_host_spec->in_addr = cl_com_copy_in_addr(host_elem->host_spec->in_addr);
363
if ( new_host_spec->in_addr == NULL) {
364
cl_com_free_hostspec(&new_host_spec);
365
cl_raw_list_unlock(source);
366
cl_host_list_cleanup(destination);
367
return CL_RETVAL_MALLOC;
370
new_host_spec->in_addr = NULL;
373
if ( host_elem->host_spec->hostent) {
374
new_host_spec->hostent = cl_com_copy_hostent(host_elem->host_spec->hostent);
375
if ( new_host_spec->hostent == NULL) {
376
cl_com_free_hostspec(&new_host_spec);
377
cl_raw_list_unlock(source);
378
cl_host_list_cleanup(destination);
379
return CL_RETVAL_MALLOC;
382
new_host_spec->hostent = NULL;
385
cl_host_list_append_host((*destination), new_host_spec, 0);
386
host_elem = cl_host_list_get_next_elem(host_elem);
389
ret_val = cl_raw_list_unlock( source );
393
#ifdef __CL_FUNCTION__
394
#undef __CL_FUNCTION__
396
#define __CL_FUNCTION__ "cl_host_list_get_data()"
397
cl_host_list_data_t* cl_host_list_get_data(cl_raw_list_t* list_p) {
399
cl_host_list_data_t* ldata = NULL;
400
cl_raw_list_t* hostlist = NULL;
402
if (list_p == NULL) {
403
hostlist = cl_com_get_host_list();
407
if (hostlist == NULL) {
408
CL_LOG(CL_LOG_WARNING,"no global hostlist");
412
ldata = (cl_host_list_data_t*) hostlist->list_data;
417
#ifdef __CL_FUNCTION__
418
#undef __CL_FUNCTION__
420
#define __CL_FUNCTION__ "cl_host_list_set_alias_file_dirty()"
421
int cl_host_list_set_alias_file_dirty(cl_raw_list_t* list_p) {
423
cl_host_list_data_t* ldata = NULL;
425
if (list_p == NULL ) {
426
return CL_RETVAL_PARAMS;
430
ret_val = cl_raw_list_lock(list_p);
431
if (ret_val != CL_RETVAL_OK) {
435
/* list_p should be a hostlist */
436
ldata = (cl_host_list_data_t*) list_p->list_data;
438
ldata->alias_file_changed = 1;
440
cl_raw_list_unlock(list_p);
441
return CL_RETVAL_NO_FRAMEWORK_INIT;
444
/* unlock host list */
445
ret_val = cl_raw_list_unlock(list_p);
446
if (ret_val != CL_RETVAL_OK) {
455
#ifdef __CL_FUNCTION__
456
#undef __CL_FUNCTION__
458
#define __CL_FUNCTION__ "cl_host_list_set_alias_file()"
459
int cl_host_list_set_alias_file(cl_raw_list_t* list_p, const char *host_alias_file) {
461
cl_host_list_data_t* ldata = NULL;
463
if (list_p == NULL || host_alias_file == NULL) {
464
return CL_RETVAL_PARAMS;
468
ret_val = cl_raw_list_lock(list_p);
469
if (ret_val != CL_RETVAL_OK) {
473
/* list_p should be a hostlist */
474
ldata = (cl_host_list_data_t*) list_p->list_data;
476
if (ldata->host_alias_file != NULL) {
477
free(ldata->host_alias_file);
478
ldata->host_alias_file = NULL;
480
ldata->host_alias_file = strdup(host_alias_file);
481
CL_LOG_STR(CL_LOG_INFO,"using host alias file:",ldata->host_alias_file);
482
ldata->alias_file_changed = 1;
483
if (ldata->host_alias_file == NULL) {
484
cl_raw_list_unlock(list_p);
485
return CL_RETVAL_MALLOC;
488
cl_raw_list_unlock(list_p);
489
return CL_RETVAL_NO_FRAMEWORK_INIT;
492
/* unlock host list */
493
ret_val = cl_raw_list_unlock(list_p);
494
if (ret_val != CL_RETVAL_OK) {
500
#ifdef __CL_FUNCTION__
501
#undef __CL_FUNCTION__
503
#define __CL_FUNCTION__ "cl_host_list_cleanup()"
504
int cl_host_list_cleanup(cl_raw_list_t** list_p) {
505
cl_host_list_data_t* ldata = NULL;
506
cl_host_list_elem_t* elem = NULL;
508
if (list_p == NULL) {
509
/* we expect an address of an pointer */
510
return CL_RETVAL_PARAMS;
512
if (*list_p == NULL) {
513
/* we expect an initalized pointer */
514
return CL_RETVAL_PARAMS;
517
/* delete all entries in list */
518
cl_raw_list_lock(*list_p);
519
while ( (elem = cl_host_list_get_first_elem(*list_p)) != NULL) {
520
cl_raw_list_remove_elem(*list_p, elem->raw_elem);
521
cl_com_free_hostspec(&( elem->host_spec ));
524
cl_raw_list_unlock(*list_p);
526
/* clean list private data */
527
ldata = (*list_p)->list_data;
529
if (ldata->ht != NULL) {
530
sge_htable_destroy(ldata->ht);
532
cl_host_alias_list_cleanup(&(ldata->host_alias_list));
533
if (ldata->local_domain_name != NULL) {
534
free(ldata->local_domain_name);
536
if (ldata->host_alias_file != NULL) {
537
free(ldata->host_alias_file);
541
(*list_p)->list_data = NULL;
543
return cl_raw_list_cleanup(list_p);
547
#ifdef __CL_FUNCTION__
548
#undef __CL_FUNCTION__
550
#define __CL_FUNCTION__ "cl_host_list_append_host()"
551
int cl_host_list_append_host(cl_raw_list_t* list_p,cl_com_host_spec_t* host, int lock_list ) {
554
cl_host_list_elem_t* new_elem = NULL;
556
if (host == NULL || list_p == NULL) {
557
return CL_RETVAL_PARAMS;
561
if (lock_list == 1) {
562
if ( ( ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) {
567
/* add new element list */
568
new_elem = (cl_host_list_elem_t*) malloc(sizeof(cl_host_list_elem_t));
569
if (new_elem == NULL) {
570
if (lock_list == 1) {
571
cl_raw_list_unlock(list_p);
573
return CL_RETVAL_MALLOC;
576
new_elem->host_spec = host;
577
new_elem->raw_elem = cl_raw_list_append_elem(list_p, (void*) new_elem);
578
if ( new_elem->raw_elem == NULL) {
580
if (lock_list == 1) {
581
cl_raw_list_unlock(list_p);
583
return CL_RETVAL_MALLOC;
586
/* add element to hash table */
587
if (host->unresolved_name != NULL) {
588
cl_host_list_data_t* ldata = list_p->list_data;
589
if (ldata->ht != NULL) {
590
sge_htable_store(ldata->ht, host->unresolved_name, new_elem);
594
/* unlock the thread list */
595
if (lock_list == 1) {
596
if ( ( ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) {
607
#ifdef __CL_FUNCTION__
608
#undef __CL_FUNCTION__
610
#define __CL_FUNCTION__ "cl_host_list_remove_host()"
611
int cl_host_list_remove_host(cl_raw_list_t* list_p, cl_com_host_spec_t* host, int lock_list) {
612
int ret_val = CL_RETVAL_OK;
613
int function_return = CL_RETVAL_UNKOWN_HOST_ERROR;
614
cl_host_list_elem_t* elem = NULL;
616
if (list_p == NULL || host == NULL) {
617
return CL_RETVAL_PARAMS;
620
if (lock_list != 0) {
622
if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) {
627
elem = cl_host_list_get_elem_host(list_p, host->unresolved_name);
630
/* remove element from hash table */
631
if (host->unresolved_name != NULL) {
632
cl_host_list_data_t* ldata = list_p->list_data;
633
if (ldata->ht != NULL) {
634
sge_htable_delete(ldata->ht, host->unresolved_name);
638
cl_raw_list_remove_elem(list_p, elem->raw_elem);
639
function_return = CL_RETVAL_OK;
640
cl_com_free_hostspec(&(elem->host_spec));
644
if (lock_list != 0) {
646
if ((ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) {
650
return function_return;
653
#ifdef __CL_FUNCTION__
654
#undef __CL_FUNCTION__
656
#define __CL_FUNCTION__ "cl_host_list_get_elem_host()"
657
cl_host_list_elem_t* cl_host_list_get_elem_host(cl_raw_list_t* list_p, const char *unresolved_hostname) {
658
cl_host_list_elem_t *elem = NULL;
660
if (list_p != NULL && unresolved_hostname != NULL) {
661
cl_host_list_data_t* ldata = list_p->list_data;
662
if (ldata->ht != NULL) {
663
if (sge_htable_lookup(ldata->ht, unresolved_hostname, (const void **)&elem) == True) {
667
/* Search without having hash table */
668
CL_LOG(CL_LOG_INFO,"no hash table available, searching sequential");
669
elem = cl_host_list_get_first_elem(list_p);
670
while ( elem != NULL) {
671
if (elem->host_spec != NULL && elem->host_spec->unresolved_name != NULL ) {
672
if (strcmp(elem->host_spec->unresolved_name,unresolved_hostname) == 0) {
673
/* found matching element */
677
elem = cl_host_list_get_next_elem(elem);
684
#ifdef __CL_FUNCTION__
685
#undef __CL_FUNCTION__
687
#define __CL_FUNCTION__ "cl_host_list_get_first_elem()"
688
cl_host_list_elem_t* cl_host_list_get_first_elem(cl_raw_list_t* list_p) {
689
cl_raw_list_elem_t* raw_elem = cl_raw_list_get_first_elem(list_p);
691
return (cl_host_list_elem_t*) raw_elem->data;
696
#ifdef __CL_FUNCTION__
697
#undef __CL_FUNCTION__
699
#define __CL_FUNCTION__ "cl_host_list_get_least_elem()"
700
cl_host_list_elem_t* cl_host_list_get_least_elem(cl_raw_list_t* list_p) {
701
cl_raw_list_elem_t* raw_elem = cl_raw_list_get_least_elem(list_p);
703
return (cl_host_list_elem_t*) raw_elem->data;
708
#ifdef __CL_FUNCTION__
709
#undef __CL_FUNCTION__
711
#define __CL_FUNCTION__ "cl_host_list_get_next_elem()"
712
cl_host_list_elem_t* cl_host_list_get_next_elem(cl_host_list_elem_t* elem) {
713
cl_raw_list_elem_t* next_raw_elem = NULL;
716
cl_raw_list_elem_t* raw_elem = elem->raw_elem;
717
next_raw_elem = cl_raw_list_get_next_elem(raw_elem);
719
return (cl_host_list_elem_t*) next_raw_elem->data;
726
#ifdef __CL_FUNCTION__
727
#undef __CL_FUNCTION__
729
#define __CL_FUNCTION__ "cl_host_list_get_last_elem()"
730
cl_host_list_elem_t* cl_host_list_get_last_elem(cl_host_list_elem_t* elem) {
731
cl_raw_list_elem_t* last_raw_elem = NULL;
735
cl_raw_list_elem_t* raw_elem = elem->raw_elem;
736
last_raw_elem = cl_raw_list_get_last_elem(raw_elem);
738
return (cl_host_list_elem_t*) last_raw_elem->data;
744
#ifdef __CL_FUNCTION__
745
#undef __CL_FUNCTION__
747
#define __CL_FUNCTION__ "cl_com_copy_in_addr()"
748
static struct in_addr* cl_com_copy_in_addr(struct in_addr *addr) {
749
struct in_addr* copy = NULL;
755
copy = (struct in_addr*) malloc(sizeof(struct in_addr));
757
memcpy((char*) copy , addr, sizeof(struct in_addr));
762
#ifdef __CL_FUNCTION__
763
#undef __CL_FUNCTION__
765
#define __CL_FUNCTION__ "cl_com_copy_hostent()"
766
static cl_com_hostent_t* cl_com_copy_hostent(cl_com_hostent_t* hostent) {
767
cl_com_hostent_t* copy = NULL;
769
if (hostent == NULL) {
773
copy = (cl_com_hostent_t*)malloc(sizeof(cl_com_hostent_t));
777
if (hostent->he != NULL) {
778
copy->he = sge_copy_hostent(hostent->he);
779
if (copy->he == NULL ) {
780
CL_LOG(CL_LOG_ERROR,"could not copy hostent structure");