🐛
This commit is contained in:
BIN
A2/fhistogram-mt
BIN
A2/fhistogram-mt
Binary file not shown.
@ -14,7 +14,7 @@
|
||||
|
||||
#include "job_queue.h"
|
||||
|
||||
pthread_mutex_t stdout_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// err.h contains various nonstandard BSD extensions, but they are
|
||||
// very handy.
|
||||
@ -26,7 +26,12 @@ int global_histogram[8] = { 0 };
|
||||
|
||||
struct job_queue q;
|
||||
|
||||
|
||||
void update_histogram_mt(int local_histogram[8]) {
|
||||
pthread_mutex_lock(&mutex);
|
||||
merge_histogram(local_histogram, global_histogram);
|
||||
print_histogram(global_histogram);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
int fhistogram_mt(char const *path) {
|
||||
FILE *f = fopen(path, "r");
|
||||
|
BIN
A2/src.zip
BIN
A2/src.zip
Binary file not shown.
BIN
A3/src/cascade
BIN
A3/src/cascade
Binary file not shown.
@ -329,7 +329,9 @@ csc_file_t* csc_parse_file(const char* sourcefile, const char* destination)
|
||||
casc_file_data->blockcount = 1 + floor(
|
||||
(casc_file_data->targetsize - 1.0)/casc_file_data->blocksize
|
||||
);
|
||||
casc_file_data->trailblocksize = casc_file_data->targetsize - ((casc_file_data->blockcount - 1) * casc_file_data->blocksize);
|
||||
casc_file_data->trailblocksize = casc_file_data->targetsize - (
|
||||
(casc_file_data->blockcount - 1) * casc_file_data->blocksize
|
||||
);
|
||||
casc_file_data->completed = 0;
|
||||
|
||||
csc_block_t* block_list = malloc(
|
||||
@ -405,8 +407,9 @@ void get_block(csc_block_t* block, csc_peer_t peer, unsigned char* hash, char* o
|
||||
} else {
|
||||
buffer_size = MAX_LINE;
|
||||
}
|
||||
rio_t rio;
|
||||
char rio_buf[buffer_size];
|
||||
|
||||
rio_t rio;
|
||||
int peer_socket;
|
||||
peer_socket = Open_clientfd(peer.ip, peer.port);
|
||||
Rio_readinitb(&rio, peer_socket);
|
||||
@ -487,7 +490,6 @@ void get_block(csc_block_t* block, csc_peer_t peer, unsigned char* hash, char* o
|
||||
*/
|
||||
int get_peers_list(csc_peer_t** peers, uint8_t hash[32])
|
||||
{
|
||||
|
||||
rio_t rio;
|
||||
uint8_t rio_buf[MAX_LINE];
|
||||
|
||||
|
Reference in New Issue
Block a user