James Carlson 写道:
shenjian writes:
When I was fixing volo bug, I found something unusual in Nevada.
This looks like something that should be discussed on
[EMAIL PROTECTED]
I got it. :-)
I wrote one test case: client and server, to send and receive urgent
data. When there is urgent data comes, server should get the SIGURG
signal and call the signal process function to receive the urgent data,
meanwhile there should be nothing returned from recv function which is
used for receiving normal data. But in Nevada, it return -1.
Did it perhaps return with errno == EINTR?
Yes, it return with errno == EINTR. But I think it should not return.
Another unusual appearance appears in loop-back, that is client and
server in the same machine and use 127.0.0.1. The result is not correct.
What result? Need details here.
In client: send(sockfd, "56", 2, MSG_OOB).
In server, it should only take 6 as urgent, and take 5 as normal data.
But in loopback, server regards both 5 and 6 as urgent data.
I test it in snv_86 and snv_77. It works wrong both in these two
version. I think they are two new bugs. Maybe someone has update or
recover it, so I just can't make sure. If anyone knows more details
about these two problems, Could you please tell me? Thanks very much. :-)
Please provide more details about what you're actually doing (with
source if possible), the precise results you see, and consider using
one of the current development mailing lists.
Attached are the source code of client and server. you can make sure if
you like. Anyway, I am not very familiar with Nevada. So I would like to
have your suggestions if I made any mistake. Thanks very much!
Jian
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#define PORT 4000
#define MAXDATASIZE 100
int main(int argc, char *argv[])
{
int sockfd, numbytes;
char buf[MAXDATASIZE];
struct hostent *he;
struct sockaddr_in their_addr;
if (argc != 2)
{
fprintf(stderr,"usage: client hostname\n");
exit(1);
}
if ((he=gethostbyname(argv[1])) == NULL)
{
perror("gethostbyname");
exit(1);
}
printf("gethostbyname successful\n");
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror("socket");
exit(1);
}
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(PORT);
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(their_addr.sin_zero), sizeof(their_addr.sin_zero), 0);
if(connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
{
perror("connect");
exit(1);
}
printf("connect successful\n");
sleep(5);
if (send(sockfd, "123", 3, 0) == -1)
{
perror("send");
close(sockfd);
exit(0);
}
printf("Send 3 byte of normal data\n");
sleep(1);
if (send(sockfd, "4", 1, MSG_OOB)== -1)
{
perror("send");
close(sockfd);
exit(0);
}
printf("Send 1 byte of OOB data:4\n");
sleep(1);
if (send(sockfd, "56", 2, MSG_OOB) == -1)
{
perror("send");
close(sockfd);
exit(0);
}
printf("Send 2 bytes of OOB data:56\n");
sleep(1);
if (send(sockfd, "7", 1, MSG_OOB)== -1)
{
perror("send");
close(sockfd);
exit(0);
}
printf("Send 1 byte of OOB data:7\n");
sleep(1);
if (send(sockfd, "89", 1, MSG_OOB)== -1)
{
perror("send");
close(sockfd);
exit(0);
}
printf("Send 2 bytes of OOB data:89\n");
sleep(1);
if (send(sockfd, "abc", 3, MSG_OOB) == -1)
{
perror("send");
close(sockfd);
exit(0);
}
printf("Send 3 byte of OOB data:abc\n");
close(sockfd);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#define MYPORT 4000
#define BACKLOG 10
int sockfd ;
void sig_urg(int signo);
main()
{
void * old_sig_urg_handle ;
struct sockaddr_in my_addr;
struct sockaddr_in their_addr;
int sin_size;
int n ;
char buff[100] ;
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror("socket");
exit(1);
}
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(MYPORT);
my_addr.sin_addr.s_addr = INADDR_ANY;
memset(&(my_addr.sin_zero), sizeof(my_addr.sin_zero), 0);
memset(buff, 100, 0);
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
{
perror("bind");
exit(1);
}
if (listen(sockfd, BACKLOG) == -1)
{
perror("listen");
exit(1);
}
old_sig_urg_handle = signal(SIGURG, sig_urg);
sin_size = sizeof(struct sockaddr_in);
if ((sockfd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1)
{
perror("accept");
exit(1);
}
fcntl(sockfd, F_SETOWN, getpid());
while(1)
{
if((n = read(sockfd, buff, 50)) == 0)
{
perror("recv");
exit(1);
}
if(n < 0) /*in normal situation, it should return when error occures, but here use continue instead of return*/
{
perror("error occured:");
continue;
}
if(n>0)
buff[n] = 0 ;
printf("recv %d bytes: %s\n", n, buff);
}
signal(SIGURG, old_sig_urg_handle);
}
void sig_urg(int signo)
{
int n;
char buff[100]=0 ;
printf("SIGURG received\n");
n = recv(sockfd, buff, sizeof(buff)-1, MSG_OOB);
buff [ n ] = 0 ;
printf("recv %d OOB byte: %s\n", n, buff);
signal(SIGURG, sig_urg);
}
_______________________________________________
networking-discuss mailing list
[email protected]