26.5 | To see the error with the readline function that is used in Figure 26.3, build that program and start the server. Then, build the TCP echo client from Figure 6.13 that works in a batch mode correctly. Find a large text file on your system and start the client three times in a batch mode, reading from the large text file and writing its output to a temporary file. If possible, run the clients on a different host from the server. If the three clients terminate correctly (often they hang), look at their temporary output files and compare them to the input file.
Now build a version of the server using the correct readline function from Section 26.5. Rerun the test with three clients; all three clients should now work. You should also put a printf in the readline_destructor function, the readline_once function, and in the call to malloc in readline. This shows that the key is created only one time, but the memory is allocated for every thread, and that the destructor function is called for every thread. |