mirror of
https://github.com/RubyMetric/chsrc
synced 2025-06-08 11:14:03 +08:00
Remove pthread
This commit is contained in:
parent
5b39a386d0
commit
b77c7f5390
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include "xy.h"
|
#include "xy.h"
|
||||||
#include "source.h"
|
#include "source.h"
|
||||||
#include <pthread.h>
|
// #include <pthread.h>
|
||||||
|
|
||||||
#define App_Name "chsrc"
|
#define App_Name "chsrc"
|
||||||
|
|
||||||
@ -547,8 +547,6 @@ measure_speed_for_every_source (SourceInfo sources[], int size, double speed_rec
|
|||||||
|
|
||||||
double speed = 0.0;
|
double speed = 0.0;
|
||||||
|
|
||||||
pthread_t *threads = xy_malloc0 (sizeof(pthread_t) * size);
|
|
||||||
|
|
||||||
for (int i=0; i<size; i++)
|
for (int i=0; i<size; i++)
|
||||||
{
|
{
|
||||||
SourceInfo src = sources[i];
|
SourceInfo src = sources[i];
|
||||||
@ -584,22 +582,6 @@ measure_speed_for_every_source (SourceInfo sources[], int size, double speed_rec
|
|||||||
|
|
||||||
char *url_ = xy_strdup (url);
|
char *url_ = xy_strdup (url);
|
||||||
|
|
||||||
if (CliOpt_Parallel)
|
|
||||||
{
|
|
||||||
int ret = pthread_create (&threads[i], NULL, measure_speed_for_url, url_);
|
|
||||||
if (ret!=0)
|
|
||||||
{
|
|
||||||
chsrc_error ("Unable to measure speed\n");
|
|
||||||
exit (Exit_UserCause);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
get_measured[i] = true;
|
|
||||||
get_measured_n += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char *curl_result = measure_speed_for_url (url_);
|
char *curl_result = measure_speed_for_url (url_);
|
||||||
double speed = parse_and_say_curl_result (curl_result);
|
double speed = parse_and_say_curl_result (curl_result);
|
||||||
speed_records[i] = speed;
|
speed_records[i] = speed;
|
||||||
@ -608,33 +590,6 @@ measure_speed_for_every_source (SourceInfo sources[], int size, double speed_rec
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CliOpt_Parallel)
|
|
||||||
{
|
|
||||||
/* 汇总 */
|
|
||||||
char **curl_results = xy_malloc0 (sizeof(char *) * size);
|
|
||||||
for (int i=0; i<size; i++)
|
|
||||||
{
|
|
||||||
if (get_measured[i]==true)
|
|
||||||
pthread_join (threads[i], (void *)&curl_results[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i=0; i<get_measured_n; i++)
|
|
||||||
printf("\033[A\033[2K");
|
|
||||||
|
|
||||||
for (int i=0; i<size; i++)
|
|
||||||
{
|
|
||||||
if (get_measured[i]==true)
|
|
||||||
{
|
|
||||||
printf ("%s", measure_msgs[i]);
|
|
||||||
double speed = parse_and_say_curl_result (curl_results[i]);
|
|
||||||
speed_records[i] = speed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* 汇总结束 */
|
|
||||||
} /* End of if Parallel*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动测速选择镜像站和源
|
* 自动测速选择镜像站和源
|
||||||
|
Loading…
x
Reference in New Issue
Block a user