OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "nacl_io/kernel_intercept.h" | 5 #include "nacl_io/kernel_intercept.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <string.h> | 9 #include <string.h> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 if (s_state.kp->Init(ppapi) != 0) | 103 if (s_state.kp->Init(ppapi) != 0) |
104 return 1; | 104 return 1; |
105 | 105 |
106 return 0; | 106 return 0; |
107 } | 107 } |
108 | 108 |
109 int ki_is_initialized() { | 109 int ki_is_initialized() { |
110 return s_state.kp != NULL; | 110 return s_state.kp != NULL; |
111 } | 111 } |
112 | 112 |
113 void ki_uninit() { | 113 int ki_uninit() { |
114 LOG_TRACE("ki_uninit"); | 114 LOG_TRACE("ki_uninit"); |
| 115 assert(s_state.kp); |
| 116 if (s_state.kp == NULL) |
| 117 return 1; |
| 118 |
115 if (s_saved_state.kp == NULL) | 119 if (s_saved_state.kp == NULL) |
116 kernel_wrap_uninit(); | 120 kernel_wrap_uninit(); |
117 | 121 |
118 // If we are going to delete the KernelProxy don't do it | 122 // If we are going to delete the KernelProxy don't do it |
119 // until we've swapped it out. | 123 // until we've swapped it out. |
120 KernelInterceptState state_to_delete = s_state; | 124 KernelInterceptState state_to_delete = s_state; |
121 | 125 |
122 ki_pop_state(); | 126 ki_pop_state(); |
123 | 127 |
124 if (state_to_delete.kp_owned) | 128 if (state_to_delete.kp_owned) |
125 delete state_to_delete.kp; | 129 delete state_to_delete.kp; |
126 | 130 |
127 delete state_to_delete.ppapi; | 131 delete state_to_delete.ppapi; |
| 132 return 0; |
128 } | 133 } |
129 | 134 |
130 nacl_io::KernelProxy* ki_get_proxy() { | 135 nacl_io::KernelProxy* ki_get_proxy() { |
131 return s_state.kp; | 136 return s_state.kp; |
132 } | 137 } |
133 | 138 |
134 int ki_chdir(const char* path) { | 139 int ki_chdir(const char* path) { |
135 ON_NOSYS_RETURN(-1); | 140 ON_NOSYS_RETURN(-1); |
136 return s_state.kp->chdir(path); | 141 return s_state.kp->chdir(path); |
137 } | 142 } |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 int ki_socket(int domain, int type, int protocol) { | 617 int ki_socket(int domain, int type, int protocol) { |
613 ON_NOSYS_RETURN(-1); | 618 ON_NOSYS_RETURN(-1); |
614 return s_state.kp->socket(domain, type, protocol); | 619 return s_state.kp->socket(domain, type, protocol); |
615 } | 620 } |
616 | 621 |
617 int ki_socketpair(int domain, int type, int protocol, int* sv) { | 622 int ki_socketpair(int domain, int type, int protocol, int* sv) { |
618 ON_NOSYS_RETURN(-1); | 623 ON_NOSYS_RETURN(-1); |
619 return s_state.kp->socketpair(domain, type, protocol, sv); | 624 return s_state.kp->socketpair(domain, type, protocol, sv); |
620 } | 625 } |
621 #endif // PROVIDES_SOCKET_API | 626 #endif // PROVIDES_SOCKET_API |
OLD | NEW |