15-213 Lab #7 Q&A


Thursday, May 3, 2002

Question:

I'm having trouble handling the broken pipe signal. I placed the following line of code at the begining of my main function: Signal(SIGPIPE,SIG_IGN); I am using select to do things concurrently, so there aren't any children being forked. Sometimes the test driver says my program fails the broken pipe test and sometimes it says it passes. Any ideas on what i'm doing wrong???

Answer:

I'm having trouble handling the broken pipe signal. I placed the following line of code at the begining of my main function: Signal(SIGPIPE,SIG_IGN); I am using select to do things concurrently, so there aren't any children being forked. Sometimes the test driver says my program fails the broken pipe test and sometimes it says it passes. Any ideas on what i'm doing wrong???

Question:

I'm having trouble handling the broken pipe signal. I placed the following line of code at the begining of my main function: Signal(SIGPIPE,SIG_IGN); I am using select to do things concurrently, so there aren't any children being forked. Sometimes the test driver says my program fails the broken pipe test and sometimes it says it passes. Any ideas on what i'm doing wrong???

Answer:

So the staff was discussing this and it seems this may help you out: What might be causing you to fail is that your application may be segfaulting. Why? Well, here's a case that might cause it. Your application calls read(). read() blocks until there is data. I know you're using select, but maybe there's an error in your code's logic that allows it to call read() when it would block. Now, let a SIGPIPE happen. Your application will ignore the signal. read() will immediately return with an error code. Note that read() returns a signed long (ssize_t - no spelling error). This error code may well be negative. If your code doesn't actually check for ((x = read()) <= 0), and you immediately just call write(..., x), x will be interpreted as an unsigned long (size_t - note no leading s), which means it'll be some huge number. This will cause write to go well beyond any allocated pages in the virtual memory space. Hence causing a segfault. Just a thought.


Monday, April 29, 2002

Question:

I'm having trouble handling the broken pipe signal. I placed the following line of code at the begining of my main function: Signal(SIGPIPE,SIG_IGN); I am using select to do things concurrently, so there aren't any children being forked. Sometimes the test driver says my program fails the broken pipe test and sometimes it says it passes. Any ideas on what i'm doing wrong?

Answer:

You may want to actually try handling SIGPIPE and closing the connection safely that way. Make sure that whatever got interrupted by the signal will know that the connection is closed (that means error checking on stuff that usually wouldn't fail at all - e.g., write()).


Friday, April 26, 2002

Question:

How scalable does the filter code for Lab #7 need to be? Should we implement a hash table or balanced tree, or is a linked list scan enough?

Answer:

We don't care about the scalability of the filters. The goal of this lab is about thread and network programming. So pick whatever data structure you want.


Question:

Do we need to account for multiple GET requests in the same connection. In other words, do we need to watch for the Keep-alive directive in the request headers?

Answer:

No, these are HTTP/1.1 persistent connections. They are not required for the lab.


Thursday, April 25, 2002

Question:

In the proxy.filter file, there appear to be spaces at the end of some of the lines. It's a little easier for me to determine if a request should be blocked if those space aren't there. Is it ok to take them out?

Answer:

You'd better take the space out by code since you will be handing in the proxy.c file only. It's only 3 lines of code.


Question:

I noticed that csapp.h is included at the top of proxy.c. So I'm wondering, can we use open_listenfd in our initialization, as opposed to using the socket, bind, and listen commands directly?

Answer:

Yes, you can. Make sure you understand what it does and use them correctly.


Question:

Are we allowed to use the RIO package listed in the textbook?

Answer:

Yep. The csapp.c provided only contains the old version of the package. So if you want to use the new version of the code, please copy the code to proxy.c file since you will be handing in that file only.