mirror of
https://github.com/0intro/libtask
synced 2024-11-24 22:59:43 +03:00
798c8c6df8
fd.c:230 negative_returns: fd is passed to a parameter that cannot be negative. net.c:65 check_return: Calling setsockopt(fd, 1, 2, (char *)&n, 4U) without checking return value. net.c:77 check_return: Calling fdnoblock(fd) without checking return value. net.c:112 check_return: Calling fdnoblock(cfd) without checking return value. net.c:114 check_return: Calling setsockopt(cfd, IPPROTO_TCP, 1, (char *)&one, 4U) without checking return value. net.c:144 leaked_storage: Variable result going out of scope leaks the storage it points to. net.c:168 check_return: Calling fdnoblock(fd) without checking return value. net.c:173 check_return: Calling setsockopt(fd, 1, 6, &n, 4U) without checking return value. net.c:206 check_return: Calling getsockopt(fd, 1, 4, (void *)&n, &sn) without checking return value. task.c:59 negative_returns: fd is passed to a parameter that cannot be negative. tcpload.c:50 Calling fdread without checking return value (as is done elsewhere 4 out of 5 times). tcpproxy.c:51 check_return: Calling fdnoblock(fd) without checking return value.
53 lines
784 B
C
53 lines
784 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <task.h>
|
|
#include <stdlib.h>
|
|
|
|
enum
|
|
{
|
|
STACK = 32768
|
|
};
|
|
|
|
char *server;
|
|
int port;
|
|
|
|
void fetchtask(void*);
|
|
|
|
void
|
|
taskmain(int argc, char **argv)
|
|
{
|
|
int i, n;
|
|
|
|
if(argc != 4){
|
|
fprintf(stderr, "usage: httpload n server port\n");
|
|
taskexitall(1);
|
|
}
|
|
n = atoi(argv[1]);
|
|
server = argv[2];
|
|
port = atoi(argv[3]);
|
|
|
|
for(i=0; i<n; i++)
|
|
taskcreate(fetchtask, 0, STACK);
|
|
}
|
|
|
|
void
|
|
fetchtask(void *v)
|
|
{
|
|
int fd, i;
|
|
char buf[512];
|
|
|
|
(void)v;
|
|
|
|
for(i=0; i<1000; i++){
|
|
if((fd = netdial(TCP, server, port)) < 0){
|
|
fprintf(stderr, "dial %s: %s (%s)\n", server, strerror(errno), taskgetstate());
|
|
continue;
|
|
}
|
|
snprintf(buf, sizeof buf, "xxxxxxxxxx");
|
|
fdwrite(fd, buf, strlen(buf));
|
|
close(fd);
|
|
}
|
|
}
|