Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: libraries/nacl-mounts/base/KernelProxy.h

Issue 10392070: Socket subsystem implementation (Closed) Base URL: http://naclports.googlecode.com/svn/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libraries/nacl-mounts/base/KernelProxy.h
===================================================================
--- libraries/nacl-mounts/base/KernelProxy.h (revision 594)
+++ libraries/nacl-mounts/base/KernelProxy.h (working copy)
@@ -8,6 +8,7 @@
#include <errno.h>
#ifdef __GLIBC__
+#include <netdb.h>
#include <poll.h>
#endif
#include <pthread.h>
@@ -18,8 +19,9 @@
#include <string>
#include "../base/Mount.h"
#include "../base/MountManager.h"
+#include "../net/BaseSocketSubSystem.h"
#include "../util/Path.h"
-#include "../util/SimpleAutoLock.h"
+#include "../util/PthreadHelpers.h"
#include "../util/SlotAllocator.h"
// KernelProxy handles all of the system calls. System calls are either
@@ -33,12 +35,18 @@
// Obtain the singleton instance of the kernel proxy. If no instance
// has been instantiated, one will be instantiated and returned.
static KernelProxy *KPInstance();
+#ifdef __GLIBC__
+ // Set socket subsystem reference (not in constructor because it needs to be
+ // created separately and only if you need sockets in your app)
+ void SetSocketSubSystem(BaseSocketSubSystem* bss);
+#endif
// System calls handled by KernelProxy (not mount-specific)
int chdir(const std::string& path);
bool getcwd(std::string *buf, size_t size);
bool getwd(std::string *buf);
int dup(int oldfd);
+ int dup2(int oldfd, int newfd);
// System calls that take a path as an argument:
// The kernel proxy will look for the Node associated to the path. To
@@ -109,6 +117,13 @@
const struct timeval *timeout, void* sigmask);
int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+ struct hostent* gethostbyname(const char* name);
+ int getaddrinfo(const char* hostname, const char* servname,
+ const struct addrinfo* hints, struct addrinfo** res);
+ void freeaddrinfo(struct addrinfo* ai);
+ int getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, socklen_t hostlen,
+ char *serv, socklen_t servlen, unsigned int flags);
int getsockopt(int sockfd, int level, int optname, void *optval,
socklen_t* optlen);
int setsockopt(int sockfd, int level, int optname, const void *optval,
@@ -128,21 +143,41 @@
#endif
MountManager *mm() { return &mm_; }
+#ifdef __GLIBC__
+ int AddSocket(Socket* stream);
+ void RemoveSocket(int fd);
+
+ int IsReady(int nfds, fd_set* fds, bool (Socket::*is_ready)(),
+ bool apply);
+ Cond& select_cond() { return select_cond_; }
+ Mutex& select_mutex() { return select_mutex_; }
+#endif // __GLIBC__
private:
struct FileDescriptor {
// An index in open_files_ table
int handle;
};
+ // used for select() signals
+ Cond select_cond_;
+ Mutex select_mutex_;
+
struct FileHandle {
Mount *mount;
+#ifdef __GLIBC__
+ Socket* stream;
Evgeniy Stepanov 2012/06/04 10:27:20 add a comment about types of handles (file/socket/
vissi 2012/06/04 12:43:37 Done.
Evgeniy Stepanov 2012/06/04 13:10:18 where?
vissi 2012/06/04 13:26:35 Forgot to include it, please, check now.
+#endif
ino_t node;
off_t offset;
int flags;
int use_count;
pthread_mutex_t lock;
};
+ FileHandle* GetFileHandle(int fd);
+#ifdef __GLIBC__
+ BaseSocketSubSystem* socket_subsystem_;
+#endif
Path cwd_;
int max_path_len_;
MountManager mm_;
@@ -152,7 +187,6 @@
SlotAllocator<FileDescriptor> fds_;
SlotAllocator<FileHandle> open_files_;
- FileHandle *GetFileHandle(int fd);
int OpenHandle(Mount *mount, const std::string& path, int oflag, mode_t mode);
KernelProxy();

Powered by Google App Engine
This is Rietveld 408576698