Skip to content
Snippets Groups Projects
Commit 02972cdb authored by Winston Jodjana's avatar Winston Jodjana
Browse files

cleanup

parent dc7f8e32
No related branches found
No related tags found
No related merge requests found
*.o
550amtedserver
...@@ -123,13 +123,7 @@ int main(int argc, char **argv) { ...@@ -123,13 +123,7 @@ int main(int argc, char **argv) {
} }
// read file path from client and do path validation // read file path from client and do path validation
//string req_file_path(client_buffer, bytes_read);
string base_dir("."); string base_dir(".");
// if (!IsPathSafe(base_dir, req_file_path)) {
//cout << "path is not safe\n";
//close(new_client_fd);
//continue;
//}
// all good, dispatch thread and setup pollfd // all good, dispatch thread and setup pollfd
cout << " New incoming connection - " << new_client_fd << "\n"; cout << " New incoming connection - " << new_client_fd << "\n";
......
/*
* Copyright ©2020 Travis McGaha. All rights reserved. Permission is
* hereby granted to students registered for University of Washington
* CSE 333 for use solely during Summer Quarter 2020 for purposes of
* the course. No other use, copying, distribution, or modification
* is permitted without prior written consent. Copyrights for
* third-party components of this work must be honored. Instructors
* interested in reusing these course materials should contact the
* author.
*/
// Feature test macro enabling strdup (c.f., Linux Programming Interface p. 63) // Feature test macro enabling strdup (c.f., Linux Programming Interface p. 63)
#define _XOPEN_SOURCE 600 #define _XOPEN_SOURCE 600
......
/*
* Copyright ©2019 Justin Hsia. All rights reserved. Permission is
* hereby granted to students registered for University of Washington
* CSE 333 for use solely during Spring Quarter 2019 for purposes of
* the course. No other use, copying, distribution, or modification
* is permitted without prior written consent. Copyrights for
* third-party components of this work must be honored. Instructors
* interested in reusing these course materials should contact the
* author.
*/
#include <stdio.h> // for snprintf() #include <stdio.h> // for snprintf()
#include <unistd.h> // for close(), fcntl() #include <unistd.h> // for close(), fcntl()
#include <sys/types.h> // for socket(), getaddrinfo(), etc. #include <sys/types.h> // for socket(), getaddrinfo(), etc.
......
...@@ -6,8 +6,8 @@ extern "C" ...@@ -6,8 +6,8 @@ extern "C"
#include <pthread.h> // for the pthread threading/mutex functions #include <pthread.h> // for the pthread threading/mutex functions
} }
#include <stdint.h> // for uint32_t, etc. #include <stdint.h> // for uint32_t, etc.
#include <list> // for std::list #include <list> // for std::list
#include <string> #include <string>
#include "./verify550.h" // For asserts #include "./verify550.h" // For asserts
...@@ -16,8 +16,9 @@ using namespace std; ...@@ -16,8 +16,9 @@ using namespace std;
static const int FILE_BUFFER_SIZE = 2000000; static const int FILE_BUFFER_SIZE = 2000000;
class ThreadPool { class ThreadPool
public: {
public:
// Construct a new ThreadPool with a certain number of worker // Construct a new ThreadPool with a certain number of worker
// threads. Arguments: // threads. Arguments:
// //
...@@ -74,23 +75,21 @@ private: ...@@ -74,23 +75,21 @@ private:
pthread_t *thread_array_; pthread_t *thread_array_;
}; };
typedef struct Work { typedef struct Work
string filepath; {
//char buffer[FILE_BUFFER_SIZE]; // Buffer for main thread to read file contents from worker thread string filepath; // String for the filepath of the file the client is requesting for
string buffer; string buffer; // Buffer for main thread to read file contents from worker thread
//int written; // Number of bytes (char) that the worker thread has written to the buffer int pipe_fd; // Write end for the pipe. Used to notify main thread that the worker is done writing the file contents.
int pipe_fd; // Write end for the pipe. Used to notify main thread that the worker is done writing the file contents. int client_fd; // Client that this work is for
int client_fd; // Client that this work is for
} Work; } Work;
class HttpServerTask : public ThreadPool::Task { class HttpServerTask : public ThreadPool::Task
public: {
public:
explicit HttpServerTask(ThreadPool::thread_task_fn f) explicit HttpServerTask(ThreadPool::thread_task_fn f)
: ThreadPool::Task(f) {} : ThreadPool::Task(f) {}
Work *work; // Struct to hold data for passing between main and worker thread Work *work; // Struct to hold data for passing between main and worker thread
}; };
#endif // THREADPOOL_H_ #endif // THREADPOOL_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment