@@ -26,12 +26,6 @@ using namespace Homa;
2626#define DECLARE_SHENANGO_FUNC (ReturnType, MethodName, ...) \
2727 extern ReturnType (*shenango_##MethodName)(__VA_ARGS__);
2828
29- /* *
30- * Fast thread-local slab-based memory allocation.
31- */
32- DECLARE_SHENANGO_FUNC (void *, smalloc, size_t )
33- DECLARE_SHENANGO_FUNC(void , sfree, void *)
34-
3529/* *
3630 * Protect RCU read-side critical sections.
3731 */
@@ -165,30 +159,13 @@ homa_driver_free(homa_driver drv)
165159}
166160
167161/* *
168- * An almost trivial implementation of Mailbox. This class is essentially
169- * a wrapper around a socket table entry in Shenango (i.e., struct trans_entry).
170- *
162+ * A trivial implementation of Mailbox for catching errors.
171163 */
172164class ShenangoMailbox final : public Mailbox {
173165 public:
174- explicit ShenangoMailbox (void * trans_entry)
175- : trans_entry(trans_entry)
176- {}
177-
166+ explicit ShenangoMailbox () = default;
178167 ~ShenangoMailbox () override = default ;
179168
180- void close () override
181- {
182- this ->~ShenangoMailbox ();
183- shenango_sfree (this );
184- shenango_rcu_read_unlock ();
185- }
186-
187- void deliver (InMessage* message) override
188- {
189- shenango_homa_mb_deliver (trans_entry, homa_inmsg{message});
190- }
191-
192169 InMessage* retrieve (bool blocking) override
193170 {
194171 (void )blocking;
@@ -199,10 +176,6 @@ class ShenangoMailbox final : public Mailbox {
199176 {
200177 PANIC (" Shenango should never call Homa::Socket::shutdown" );
201178 }
202-
203- private:
204- // / An opaque pointer to "struct trans_entry" in Shenango.
205- void * const trans_entry;
206179};
207180
208181/* *
@@ -226,21 +199,22 @@ class ShenangoMailboxDir final : MailboxDir {
226199 {
227200 // Shenango doesn't rely on Homa::Socket to receive messages,
228201 // so there is no need to assign a real mailbox to SocketImpl.
229- static ShenangoMailbox dummyMailbox ( nullptr ) ;
202+ static ShenangoMailbox dummyMailbox;
230203 (void )port;
231204 return &dummyMailbox;
232205 }
233206
234- Mailbox* open (uint16_t port) override
207+ bool deliver (uint16_t port, InMessage* message ) override
235208 {
236- SocketAddress laddr = {local_ip, port};
209+ // The socket table in Shenango is protected by an RCU.
237210 shenango_rcu_read_lock ();
211+ SocketAddress laddr = {local_ip, port};
238212 void * trans_entry = shenango_trans_table_lookup (proto, laddr, {});
239- if (! trans_entry) {
240- return nullptr ;
213+ if (trans_entry) {
214+ shenango_homa_mb_deliver (trans_entry, homa_inmsg{message}) ;
241215 }
242- void * backing = shenango_smalloc ( sizeof (ShenangoMailbox) );
243- return new (backing) ShenangoMailbox (trans_entry) ;
216+ shenango_rcu_read_unlock ( );
217+ return trans_entry != nullptr ;
244218 }
245219
246220 bool remove (uint16_t port) override
0 commit comments