@@ -74,9 +74,8 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
74
74
}
75
75
76
76
if ( typ != Type :: STREAM ) && ( typ != Type :: DGRAM ) {
77
- let cause: String = format ! ( "socket type not supported (type={:?})" , typ) ;
78
- error ! ( "socket(): {}" , cause) ;
79
- return Err ( Fail :: new ( libc:: ENOTSUP , & cause) ) ;
77
+ error ! ( "socket(): socket type not supported (type={:?})" , typ) ;
78
+ return Err ( Fail :: new ( libc:: ENOTSUP , "socket type not supported" ) ) ;
80
79
}
81
80
82
81
let queue: SharedNetworkQueue < T > = SharedNetworkQueue :: new ( domain, typ, & mut self . transport ) ?;
@@ -109,24 +108,22 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
109
108
// We only support the wildcard address for UDP sockets.
110
109
// FIXME: https://github.com/demikernel/demikernel/issues/189
111
110
if * socket_addrv4. ip ( ) == Ipv4Addr :: UNSPECIFIED && self . get_shared_queue ( & qd) ?. qtype ( ) != QType :: UdpSocket {
112
- let cause: String = format ! ( "cannot bind to wildcard address (qd={:?})" , qd) ;
113
- error ! ( "bind(): {}" , cause) ;
114
- return Err ( Fail :: new ( libc:: ENOTSUP , & cause) ) ;
111
+ error ! ( "bind(): cannot bind to wildcard address (qd={:?})" , qd) ;
112
+ return Err ( Fail :: new ( libc:: ENOTSUP , "cannot bind to wildcard address" ) ) ;
115
113
}
116
114
117
115
// We only support the wildcard address for UDP sockets.
118
116
// FIXME: https://github.com/demikernel/demikernel/issues/582
119
117
if socket_addr. port ( ) == 0 && self . get_shared_queue ( & qd) ?. qtype ( ) != QType :: UdpSocket {
120
- let cause: String = format ! ( "cannot bind to port 0 (qd={:?})" , qd) ;
121
- error ! ( "bind(): {}" , cause) ;
122
- return Err ( Fail :: new ( libc:: ENOTSUP , & cause) ) ;
118
+ error ! ( "bind(): cannot bind to port 0 (qd={:?})" , qd) ;
119
+ return Err ( Fail :: new ( libc:: ENOTSUP , "cannot bind to port 0" ) ) ;
123
120
}
124
121
125
122
if self . runtime . is_addr_in_use ( socket_addrv4) {
126
- let cause: String = format ! ( "address is already bound to a socket (qd={:?}" , qd) ;
127
- error ! ( "bind(): {}" , & cause) ;
128
- return Err ( Fail :: new ( libc:: EADDRINUSE , & cause) ) ;
123
+ error ! ( "bind(): address is already bound to a socket (qd={:?}" , qd) ;
124
+ return Err ( Fail :: new ( libc:: EADDRINUSE , "address is already bound to a socket" ) ) ;
129
125
}
126
+
130
127
self . get_shared_queue ( & qd) ?. bind ( socket_addr) ?;
131
128
// Insert into address to queue descriptor table.
132
129
self . runtime
@@ -142,12 +139,10 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
142
139
143
140
// We use this API for testing, so we must check again.
144
141
if !( ( backlog > 0 ) && ( backlog <= SOMAXCONN as usize ) ) {
145
- let cause: String = format ! ( "invalid backlog length: {:?}" , backlog) ;
146
- warn ! ( "{}" , cause) ;
147
- return Err ( Fail :: new ( libc:: EINVAL , & cause) ) ;
142
+ warn ! ( "invalid backlog length: {:?}" , backlog) ;
143
+ return Err ( Fail :: new ( libc:: EINVAL , "invalid backlog length" ) ) ;
148
144
}
149
145
150
- // Issue listen operation.
151
146
self . get_shared_queue ( & qd) ?. listen ( backlog)
152
147
}
153
148
@@ -303,23 +298,23 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
303
298
/// coroutine that asynchronously runs the push and any synchronous multi-queue functionality before the push
304
299
/// begins.
305
300
pub fn push ( & mut self , qd : QDesc , sga : & demi_sgarray_t ) -> Result < QToken , Fail > {
306
- let bufs = clone_sgarray ( sga) ?;
307
- if bufs . is_empty ( ) {
308
- let cause = "zero-length list of buffers" ;
309
- warn ! ( "push(): {}" , cause ) ;
310
- return Err ( Fail :: new ( libc:: EINVAL , & cause ) ) ;
301
+ let buffers = clone_sgarray ( sga) ?;
302
+
303
+ if buffers. is_empty ( ) {
304
+ warn ! ( "push(): buffers cannot be empty" ) ;
305
+ return Err ( Fail :: new ( libc:: EINVAL , "buffers cannot be empty" ) ) ;
311
306
}
312
- for buf in bufs . iter ( ) {
313
- if buf . is_empty ( ) {
314
- let cause = "zero-length buffer" ;
315
- warn ! ( "push(): {}" , cause ) ;
316
- return Err ( Fail :: new ( libc:: EINVAL , & cause ) ) ;
307
+
308
+ for buffer in buffers . iter ( ) {
309
+ if buffer. is_empty ( ) {
310
+ warn ! ( "push(): empty buffer" ) ;
311
+ return Err ( Fail :: new ( libc:: EINVAL , "empty buffer" ) ) ;
317
312
} ;
318
313
}
319
314
320
315
let mut queue: SharedNetworkQueue < T > = self . get_shared_queue ( & qd) ?;
321
316
let coroutine_constructor = || -> Result < QToken , Fail > {
322
- let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, bufs , None ) . fuse ( ) ) ;
317
+ let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, buffers , None ) . fuse ( ) ) ;
323
318
self . runtime
324
319
. clone ( )
325
320
. schedule_coroutine ( "ioc::network::libos::push" , coroutine)
@@ -360,14 +355,14 @@ impl<T: NetworkTransport> SharedNetworkLibOS<T> {
360
355
pub fn pushto ( & mut self , qd : QDesc , sga : & demi_sgarray_t , remote : SocketAddr ) -> Result < QToken , Fail > {
361
356
trace ! ( "pushto() qd={:?}" , qd) ;
362
357
363
- let bufs : ArrayVec < DemiBuffer , DEMI_SGARRAY_MAXLEN > = clone_sgarray ( sga) ?;
364
- if bufs . is_empty ( ) {
365
- return Err ( Fail :: new ( libc:: EINVAL , "zero buffers to send " ) ) ;
358
+ let buffers : ArrayVec < DemiBuffer , DEMI_SGARRAY_MAXLEN > = clone_sgarray ( sga) ?;
359
+ if buffers . is_empty ( ) {
360
+ return Err ( Fail :: new ( libc:: EINVAL , "buffers cannot be empty " ) ) ;
366
361
}
367
362
368
363
let mut queue: SharedNetworkQueue < T > = self . get_shared_queue ( & qd) ?;
369
364
let coroutine_constructor = || -> Result < QToken , Fail > {
370
- let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, bufs , Some ( remote) ) . fuse ( ) ) ;
365
+ let coroutine = Box :: pin ( self . clone ( ) . push_coroutine ( qd, buffers , Some ( remote) ) . fuse ( ) ) ;
371
366
self . runtime
372
367
. clone ( )
373
368
. schedule_coroutine ( "ioc::network::libos::pushto" , coroutine)
0 commit comments