mirror of
https://github.com/fumiama/C302.git
synced 2025-01-18 20:20:13 +09:00
优化代码结构
This commit is contained in:
parent
281cbf876f
commit
8ecab42ea4
10
c302.c
10
c302.c
@ -21,15 +21,13 @@ int main(int argc, char **argv) {
|
|||||||
http_error(HTTP500, "Argument Count Error.");
|
http_error(HTTP500, "Argument Count Error.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
srand(time(NULL));
|
uint32_t i = time(NULL) % (sizeof(urls)/sizeof(char*));
|
||||||
uint32_t i = rand() % (sizeof(urls)/sizeof(char*));
|
|
||||||
uint32_t len = sizeof(HTTP302HEAD)-1 + urlsl[i] + 4 + sizeof(CONTENT)-1;
|
uint32_t len = sizeof(HTTP302HEAD)-1 + urlsl[i] + 4 + sizeof(CONTENT)-1;
|
||||||
const struct iovec iov[5] = {
|
const struct iovec iov[4] = {
|
||||||
{(void *)&len, sizeof(uint32_t)},
|
{(void *)&len, sizeof(uint32_t)},
|
||||||
{HTTP302HEAD, sizeof(HTTP302HEAD)-1},
|
{HTTP302HEAD, sizeof(HTTP302HEAD)-1},
|
||||||
{(void *)urls[i], urlsl[i]},
|
{(void *)urls[i], urlsl[i]},
|
||||||
{"\r\n\r\n", 4},
|
{"\r\n\r\n" CONTENT, 4+sizeof(CONTENT)-1}
|
||||||
{CONTENT, sizeof(CONTENT)-1}
|
|
||||||
};
|
};
|
||||||
return writev(1, (const struct iovec *)&iov, 5) != len+sizeof(uint32_t);
|
return writev(1, (const struct iovec *)&iov, 4) != len+sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user