unix: implement uv_import() and uv_export()
This commit is contained in:
parent
abdc3efffe
commit
e34dc13496
@ -193,9 +193,7 @@ typedef void* uv_lib_t;
|
|||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
#define UV_STREAM_INFO_PRIVATE_FIELDS \
|
#define UV_STREAM_INFO_PRIVATE_FIELDS \
|
||||||
union { \
|
int fd;
|
||||||
int fd; \
|
|
||||||
};
|
|
||||||
|
|
||||||
/* UV_FS_EVENT_PRIVATE_FIELDS */
|
/* UV_FS_EVENT_PRIVATE_FIELDS */
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
|||||||
@ -967,12 +967,39 @@ int uv_read_stop(uv_stream_t* stream) {
|
|||||||
|
|
||||||
|
|
||||||
int uv_export(uv_stream_t* stream, uv_stream_info_t* info) {
|
int uv_export(uv_stream_t* stream, uv_stream_info_t* info) {
|
||||||
/* Implement me */
|
int fd;
|
||||||
return uv__new_artificial_error(UV_ENOSYS);
|
|
||||||
|
if (stream->type != UV_TCP) {
|
||||||
|
uv__set_artificial_error(stream->loop, UV_EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = uv__dup(stream->fd);
|
||||||
|
|
||||||
|
if (fd == -1) {
|
||||||
|
uv__set_sys_error(stream->loop, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
info->type = stream->type;
|
||||||
|
info->fd = fd;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int uv_import(uv_stream_t* stream, uv_stream_info_t* info) {
|
int uv_import(uv_stream_t* stream, uv_stream_info_t* info) {
|
||||||
/* Implement me */
|
if (info->type != UV_TCP) {
|
||||||
return uv__new_artificial_error(UV_ENOSYS);
|
uv__set_artificial_error(stream->loop, UV_EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stream->fd != -1) {
|
||||||
|
uv__set_artificial_error(stream->loop, UV_EALREADY);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->fd = info->fd;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user