ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Smersh/Daemon.cpp
(Generate patch)

Comparing Smersh/Daemon.cpp (file contents):
Revision 178 by Douglas Thrift, 2004-06-29T13:15:51-07:00 vs.
Revision 179 by Douglas Thrift, 2004-07-02T21:16:12-07:00

# Line 20 | Line 20 | void Daemon::serve(int port, bool fork,
20  
21          if (fork)
22          {
23 <                switch (::fork())
23 >                switch (pid_t pid = ::fork())
24                  {
25                  case -1:
26                          cerr << program << ": fork()\n";
# Line 29 | Line 29 | void Daemon::serve(int port, bool fork,
29                  case 0:
30                          break;
31                  default:
32 +                        cout << pid << '\n';
33                          return;
34                  }
35          }
# Line 37 | Line 38 | void Daemon::serve(int port, bool fork,
38  
39          while (true)
40          {
41 <                api::TcpSocket* client(new api::TcpSocket());
41 >                Client* client (new Client);
42  
43 <                server.Accept(*client);
43 >                server.Accept(client->socket, &client->ip);
44  
45                  api::Thread thread(etl::BindAll(&Daemon::handle, self, client));
46          }
# Line 125 | Line 126 | string Daemon::date(bool log)
126          return when;
127   }
128  
129 < string Daemon::ip(const api::TcpSocket& socket)
129 > int Daemon::handle(Client* client)
130   {
131 <        api::InternetAddress address(socket.GetAddress());
131 <
132 <        return inet_ntoa(address->sin_addr);
133 < }
134 <
135 < int Daemon::handle(api::TcpSocket* client)
136 < {
137 <        ios::InputOutputStreamBufAdapter adapter(*client);
131 >        ios::InputOutputStreamBufAdapter adapter(client->socket);
132          iostream sio(&adapter);
133          Environment env;
134          stringstream post;
# Line 168 | Line 162 | int Daemon::handle(api::TcpSocket* clien
162  
163          ofstream fout(this->log.c_str(), ios_base::app);
164  
165 <        fout << ip(*client) << " - - " << date(true) << ' ' << log.str() << '\n';
165 >        fout << inet_ntoa(client->ip->sin_addr) << " - - " << date(true) << ' '
166 >                << log.str() << '\n';
167          sio << flush;
168  
169 <        client->ShutdownWrite();
169 >        client->socket.ShutdownWrite();
170  
171          delete client;
172   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines