update NSPR to 4.24 and keep NSPR Bug 1586070 and win64 patch intact.

This commit is contained in:
Roy Tam 2020-01-03 13:34:04 +08:00
commit 0b9855b841
487 changed files with 42933 additions and 48679 deletions

View file

@ -55,9 +55,12 @@ static PRStatus PrintAddress(const PRNetAddr* address)
{
char buffer[ADDR_BUFFER];
PRStatus rv = PR_NetAddrToString(address, buffer, sizeof(buffer));
if (PR_SUCCESS == rv)
if (PR_SUCCESS == rv) {
PR_fprintf(err, "%s:%u\n", buffer, PR_ntohs(address->inet.port));
else PL_FPrintError(err, "PR_NetAddrToString");
}
else {
PL_FPrintError(err, "PR_NetAddrToString");
}
return rv;
} /* PrintAddress */
@ -93,21 +96,24 @@ static void PR_CALLBACK Clientel(void *arg)
data.option = PR_SockOpt_RecvBufferSize;
data.value.recv_buffer_size = (PRSize)xport_buffer;
rv = PR_SetSocketOption(xport, &data);
if (PR_FAILURE == rv)
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_SetSocketOption - ignored");
}
data.option = PR_SockOpt_SendBufferSize;
data.value.send_buffer_size = (PRSize)xport_buffer;
rv = PR_SetSocketOption(xport, &data);
if (PR_FAILURE == rv)
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_SetSocketOption - ignored");
}
}
rv = PR_Connect(xport, server_address, connect_timeout);
if (PR_FAILURE == rv)
{
PL_FPrintError(err, "PR_Connect");
if (PR_IO_TIMEOUT_ERROR != PR_GetError())
if (PR_IO_TIMEOUT_ERROR != PR_GetError()) {
PR_Sleep(connect_timeout);
}
PR_Close(xport); /* delete it and start over */
}
} while (PR_FAILURE == rv);
@ -115,7 +121,7 @@ static void PR_CALLBACK Clientel(void *arg)
do
{
bytes = PR_Recv(
xport, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);
xport, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);
PR_Lock(shared->ml);
now = PR_IntervalNow();
shared->sampled += bytes;
@ -147,13 +153,15 @@ static void Client(const char *server_name)
PRIntervalTime dally = PR_SecondsToInterval(60);
PR_fprintf(err, "Translating the name %s\n", server_name);
rv = PR_GetHostByName(server_name, buffer, sizeof(buffer), &host);
if (PR_FAILURE == rv)
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_GetHostByName");
}
else
{
if (PR_EnumerateHostEnt(
0, &host, PORT_NUMBER, &shared->server_address) < 0)
0, &host, PORT_NUMBER, &shared->server_address) < 0) {
PL_FPrintError(err, "PR_EnumerateHostEnt");
}
else
{
do
@ -189,19 +197,21 @@ static void PR_CALLBACK Servette(void *arg)
data.option = PR_SockOpt_RecvBufferSize;
data.value.recv_buffer_size = (PRSize)xport_buffer;
rv = PR_SetSocketOption(client, &data);
if (PR_FAILURE == rv)
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_SetSocketOption - ignored");
}
data.option = PR_SockOpt_SendBufferSize;
data.value.send_buffer_size = (PRSize)xport_buffer;
rv = PR_SetSocketOption(client, &data);
if (PR_FAILURE == rv)
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_SetSocketOption - ignored");
}
}
do
{
bytes = PR_Send(
client, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);
client, buffer, buffer_size, 0, PR_INTERVAL_NO_TIMEOUT);
PR_Lock(shared->ml);
now = PR_IntervalNow();
@ -238,11 +248,15 @@ static void Server(void)
}
rv = PR_InitializeNetAddr(PR_IpAddrAny, PORT_NUMBER, &server_address);
if (PR_FAILURE == rv) PL_FPrintError(err, "PR_InitializeNetAddr");
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_InitializeNetAddr");
}
else
{
rv = PR_Bind(xport, &server_address);
if (PR_FAILURE == rv) PL_FPrintError(err, "PR_Bind");
if (PR_FAILURE == rv) {
PL_FPrintError(err, "PR_Bind");
}
else
{
PRFileDesc *client;
@ -252,8 +266,10 @@ static void Server(void)
do
{
client = PR_Accept(
xport, &client_address, PR_INTERVAL_NO_TIMEOUT);
if (NULL == client) PL_FPrintError(err, "PR_Accept");
xport, &client_address, PR_INTERVAL_NO_TIMEOUT);
if (NULL == client) {
PL_FPrintError(err, "PR_Accept");
}
else
{
PR_fprintf(err, "Server accepting from ");
@ -296,37 +312,39 @@ int main(int argc, char **argv)
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
if (PL_OPT_BAD == os) continue;
if (PL_OPT_BAD == os) {
continue;
}
switch (opt->option)
{
case 0: /* Name of server */
server_name = opt->value;
break;
case 'G': /* Globular threads */
thread_scope = PR_GLOBAL_THREAD;
break;
case 'X': /* Use XTP as the transport */
protocol = 36;
break;
case '6': /* Use IPv6 */
domain = PR_AF_INET6;
break;
case 's': /* initial_streams */
initial_streams = atoi(opt->value);
break;
case 'C': /* concurrency */
concurrency = atoi(opt->value);
break;
case 'b': /* buffer size */
buffer_size = 1024 * atoi(opt->value);
break;
case 'B': /* buffer size */
xport_buffer = 1024 * atoi(opt->value);
break;
case 'h': /* user wants some guidance */
default:
Help(); /* so give him an earful */
return 2; /* but not a lot else */
case 0: /* Name of server */
server_name = opt->value;
break;
case 'G': /* Globular threads */
thread_scope = PR_GLOBAL_THREAD;
break;
case 'X': /* Use XTP as the transport */
protocol = 36;
break;
case '6': /* Use IPv6 */
domain = PR_AF_INET6;
break;
case 's': /* initial_streams */
initial_streams = atoi(opt->value);
break;
case 'C': /* concurrency */
concurrency = atoi(opt->value);
break;
case 'b': /* buffer size */
buffer_size = 1024 * atoi(opt->value);
break;
case 'B': /* buffer size */
xport_buffer = 1024 * atoi(opt->value);
break;
case 'h': /* user wants some guidance */
default:
Help(); /* so give him an earful */
return 2; /* but not a lot else */
}
}
PL_DestroyOptState(opt);
@ -335,12 +353,12 @@ int main(int argc, char **argv)
shared->ml = PR_NewLock();
PR_fprintf(err,
"This machine is %s\n",
(NULL == server_name) ? "the SERVER" : "a CLIENT");
"This machine is %s\n",
(NULL == server_name) ? "the SERVER" : "a CLIENT");
PR_fprintf(err,
"Transport being used is %s\n",
(6 == protocol) ? "TCP" : "XTP");
"Transport being used is %s\n",
(6 == protocol) ? "TCP" : "XTP");
if (PR_GLOBAL_THREAD == thread_scope)
{
@ -359,18 +377,22 @@ int main(int argc, char **argv)
}
PR_fprintf(err,
"All threads will be %s\n",
(PR_GLOBAL_THREAD == thread_scope) ? "GLOBAL" : "LOCAL");
"All threads will be %s\n",
(PR_GLOBAL_THREAD == thread_scope) ? "GLOBAL" : "LOCAL");
PR_fprintf(err, "Client buffer size will be %u\n", buffer_size);
if (-1 != xport_buffer)
PR_fprintf(
err, "Transport send & receive buffer size will be %u\n", xport_buffer);
if (NULL == server_name) Server();
else Client(server_name);
if (-1 != xport_buffer)
PR_fprintf(
err, "Transport send & receive buffer size will be %u\n", xport_buffer);
if (NULL == server_name) {
Server();
}
else {
Client(server_name);
}
return 0;
} /* main */