Skip to content

Commit

Permalink
- BasicSocket.has_threads
Browse files Browse the repository at this point in the history
always true
  • Loading branch information
ygrek committed Aug 26, 2024
1 parent b60c9bc commit 079eec6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 61 deletions.
2 changes: 1 addition & 1 deletion src/daemon/driver/driverInteractive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1911,7 +1911,7 @@ let buildinfo html buf =
tack list
(
"Features:\t",
(if BasicSocket.has_threads () then " threads" else " no-threads") ^
" threads" ^
(let s = Zlib2.zlib_version_num () in
Printf.sprintf " zlib%s" (if s <> "" then "-" ^ s else "")) ^
(if Autoconf.bzip2 then
Expand Down
3 changes: 1 addition & 2 deletions src/networks/donkey/donkeyShare.ml
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ let rec check_shared_files () =
job_creater ();
(* only try back-to-back hashing if hashing is
handled by a separate thread *)
if BasicSocket.has_threads () then
check_shared_files ()
check_shared_files ()
)
with
Wrong_file_size (real,computed) ->
Expand Down
54 changes: 7 additions & 47 deletions src/utils/lib/stubs_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

#include <string.h>
#include <ctype.h>

#include <pthread.h>
#include <signal.h>
#include <sys/time.h>

#ifdef __MORPHOS__
#include <inttypes.h>
Expand Down Expand Up @@ -680,8 +682,7 @@ value ml_setlcnumeric(value no)

#define NETDB_BUFFER_SIZE 10000

#if defined(_WIN32) || ( defined(__FreeBSD_version) && ( ((__FreeBSD_version >= 504102) && (__FreeBSD_version < 600000)) || (__FreeBSD_version >= 600029) ) )
#define GETHOSTBYADDR_IS_REENTRANT 1
#if defined(_WIN32) || defined(__CYGWIN__) || ( defined(__FreeBSD_version) && (__FreeBSD_version >= 600029) )
#define GETHOSTBYNAME_IS_REENTRANT 1
#endif /* _WIN32 */

Expand Down Expand Up @@ -738,12 +739,12 @@ static int ml_gethostbyname(char *hostname)
#else
#ifdef GETHOSTBYNAME_IS_REENTRANT
enter_blocking_section();
#endif /* GETHOSTBYNAME_IS_REENTRANT */
#endif
hp = gethostbyname(hostname);
#ifdef GETHOSTBYNAME_IS_REENTRANT
leave_blocking_section();
#endif /* GETHOSTBYNAME_IS_REENTRANT */
#endif /* HAS_GETHOSTBYNAME_R == 5 */
#endif
#endif

if (hp == (struct hostent *) NULL) return 0;

Expand Down Expand Up @@ -777,40 +778,6 @@ static value addr_list_of_job(void)
CAMLreturn(v_addr_list);
}

#if (!(HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT) && !defined(HAS_SIGWAIT))

value ml_ip_job_start(value job_v)
{
CAMLparam1(job_v);

char *hostname = String_val(Field(job_v,0));
if(ml_gethostbyname(hostname)){
Store_field(job_v, 1, addr_list_of_job())
Store_field(job_v, 2, Val_false);
} else {
Store_field(job_v, 2, Val_true);
}
CAMLreturn(Val_unit);
}

value ml_ip_job_done(value job_v)
{
return Val_true;
}


value ml_has_pthread(value unit)
{
return Val_false;
}

#else /* (!(HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT) && !defined(HAS_SIGWAIT)) */

#include <string.h>
#include <pthread.h>
#include <signal.h>
#include <sys/time.h>

static int thread_started = 0;
static int volatile ip_job_done = 1;
#define JOB_HOSTNAME_SIZE 256
Expand Down Expand Up @@ -917,13 +884,6 @@ value ml_ip_job_start(value job_v)
return Val_unit;
}

value ml_has_pthread(value unit)
{
return Val_true;
}

#endif /* (!(HAS_GETHOSTBYNAME_R || GETHOSTBYNAME_IS_REENTRANT) && !defined(HAS_SIGWAIT)) */

/*******************************************************************
Expand Down
2 changes: 0 additions & 2 deletions src/utils/net/basicSocket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ external get_fd_num : Unix.file_descr -> int = "ml_get_fd_num" "noalloc"

external select: t list -> float -> unit = "ml_select"
external use_poll : bool -> unit = "ml_use_poll"
external has_threads : unit -> bool = "ml_has_pthread"

external setsock_iptos_throughput: Unix.file_descr -> int = "ml_setsock_iptos_throughput"

Expand Down Expand Up @@ -135,7 +134,6 @@ let loop_delay = ref 0.005
let socket_keepalive = ref false
let verbose_bandwidth = ref 0
let bandwidth_second_timers = ref []
let use_threads = ref true


(*************************************************************************)
Expand Down
2 changes: 0 additions & 2 deletions src/utils/net/basicSocket.mli
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ val string_of_date : int -> string
val date_of_int : int -> float
val normalize_time : int -> int

val use_threads : bool ref
external has_threads : unit -> bool = "ml_has_pthread"
val get_rtimeout : t -> float * float
val int64_time : unit -> int64
val current_time : unit -> float
Expand Down
7 changes: 0 additions & 7 deletions src/utils/net/ip.ml
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,6 @@ let _ =
exn_log "ip_fifo immediate" f ip
with Not_found ->
(* lprintf "resolving name...\n"; *)
if !BasicSocket.use_threads &&
BasicSocket.has_threads () then
let job = {
handler = exn_log "ip_fifo handler" f;
err_handler = exn_log "ip_fifo err_handler" ferr;
Expand All @@ -340,11 +338,6 @@ let _ =
} in
current_job := Some job;
job_start job
else begin
(* lprintf "from_name ...\n"; *)
exn_log "ip_fifo no threads" f (from_name name)

end
)
| Some job ->
if job_done job then begin
Expand Down

0 comments on commit 079eec6

Please sign in to comment.