-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathqueue.c
52 lines (44 loc) · 1.05 KB
/
queue.c
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
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include "headers/queue.h"
#include "headers/main.h"
#include "headers/connection.h"
void bruter_queue_ip(char *address)
{
pthread_mutex_lock(&mutex);
for(int i = 0; i < 999999; i++)
{
if(!queue[i].queued)
{
ATOMIC_INC(&left_in_queue);
strcpy(queue[i].address, address);
queue[i].queued = 1;
break;
}
}
pthread_mutex_unlock(&mutex);
}
void *handle_queued()
{
while(1)
{
if(processing <= ACTUAL_MAX_CONS)
{
for(int i = 0; i < 999999; i++)
{
if(queue[i].queued)
{
start_connection(queue[i].address, NULL);
queue[i].queued = 0;
memset(queue[i].address, 0, 16);
ATOMIC_DEC(&left_in_queue);
}
if(processing >= ACTUAL_MAX_CONS)
break;
}
}
sleep(1);
}
}