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) {
}
// read file path from client and do path validation
//string req_file_path(client_buffer, bytes_read);
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
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)
#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 <unistd.h> // for close(), fcntl()
#include <sys/types.h> // for socket(), getaddrinfo(), etc.
......
......@@ -6,8 +6,8 @@ extern "C"
#include <pthread.h> // for the pthread threading/mutex functions
}
#include <stdint.h> // for uint32_t, etc.
#include <list> // for std::list
#include <stdint.h> // for uint32_t, etc.
#include <list> // for std::list
#include <string>
#include "./verify550.h" // For asserts
......@@ -16,8 +16,9 @@ using namespace std;
static const int FILE_BUFFER_SIZE = 2000000;
class ThreadPool {
public:
class ThreadPool
{
public:
// Construct a new ThreadPool with a certain number of worker
// threads. Arguments:
//
......@@ -74,23 +75,21 @@ private:
pthread_t *thread_array_;
};
typedef struct Work {
string filepath;
//char buffer[FILE_BUFFER_SIZE]; // Buffer for main thread to read file contents from worker thread
string buffer;
//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 client_fd; // Client that this work is for
typedef struct Work
{
string filepath; // String for the filepath of the file the client is requesting for
string buffer; // Buffer for main thread to read file contents from worker thread
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
} Work;
class HttpServerTask : public ThreadPool::Task {
public:
class HttpServerTask : public ThreadPool::Task
{
public:
explicit HttpServerTask(ThreadPool::thread_task_fn f)
: ThreadPool::Task(f) {}
Work *work; // Struct to hold data for passing between main and worker thread
};
#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