Difference between revisions of "Messaging"

(socket messaging)
(messaging diagrams)
Line 1: Line 1:
 
 
Multiple [[smbd]] processes usually run simultaneously - a main daemon process and couple of connections processes. Samba code has special API that allows different processes send messages each other. There are two implementations of the [[messaging]] code - different in current [[Samba3]] and [[Samba4]] code.
 
Multiple [[smbd]] processes usually run simultaneously - a main daemon process and couple of connections processes. Samba code has special API that allows different processes send messages each other. There are two implementations of the [[messaging]] code - different in current [[Samba3]] and [[Samba4]] code.
  
Line 18: Line 17:
 
Process sends a message to other process with special function [[message_send_pid]] and to all processes with [[message_send_all]].
 
Process sends a message to other process with special function [[message_send_pid]] and to all processes with [[message_send_all]].
 
Each process should call [[message_dispatch]] routinely to check if messages were received and run appropriate handler.
 
Each process should call [[message_dispatch]] routinely to check if messages were received and run appropriate handler.
 +
 +
[[Image:messaging-tdb.png]] (you can see the image [http://fedoseev.net/samba/messaging-tdb.png here])
 +
 +
(you can see source SVG [http://fedoseev.net/samba/messaging.svg image])
  
 
=== Samba 4 implementation ===
 
=== Samba 4 implementation ===
  
 
This implementation uses UNIX domain sockets. Each [[smbd]] listens on a unix domain socket with the name based on its pid. All sockets are located in ''var/locks'' directory. One message is packed into one datagram, so now we have message size problem - there is no way to send messages with size larger than allowed by a datagram.
 
This implementation uses UNIX domain sockets. Each [[smbd]] listens on a unix domain socket with the name based on its pid. All sockets are located in ''var/locks'' directory. One message is packed into one datagram, so now we have message size problem - there is no way to send messages with size larger than allowed by a datagram.
 +
 +
[[Image:messaging-socket.png]] (you can see the image [http://fedoseev.net/samba/messaging-socket.png here])
  
 
== Testing ==
 
== Testing ==
  
 
You can test messaging speed with LOCAL-MESSAGING test from [[Samba4]] [[smbtorture]]. Present implementations have almost similar speed.
 
You can test messaging speed with LOCAL-MESSAGING test from [[Samba4]] [[smbtorture]]. Present implementations have almost similar speed.

Revision as of 13:01, 9 May 2006

Multiple smbd processes usually run simultaneously - a main daemon process and couple of connections processes. Samba code has special API that allows different processes send messages each other. There are two implementations of the messaging code - different in current Samba3 and Samba4 code.

Samba 3 implementation

This implementaion uses TDB file for storing messages and UNIX signals for notifying message receiver.

All messages are stored in messages.tdb file (one can find it in var/locks directory). Each message is just a database record that has six fields:

  • messaging version (there is only one version now - 1)
  • message type
  • sender process id
  • receiver process id
  • message data length
  • message data

There are lot of message types in Samba3, you can see them all in include/messages.h file.

Process sends a message to other process with special function message_send_pid and to all processes with message_send_all. Each process should call message_dispatch routinely to check if messages were received and run appropriate handler.

Messaging-tdb.png (you can see the image here)

(you can see source SVG image)

Samba 4 implementation

This implementation uses UNIX domain sockets. Each smbd listens on a unix domain socket with the name based on its pid. All sockets are located in var/locks directory. One message is packed into one datagram, so now we have message size problem - there is no way to send messages with size larger than allowed by a datagram.

Messaging-socket.png (you can see the image here)

Testing

You can test messaging speed with LOCAL-MESSAGING test from Samba4 smbtorture. Present implementations have almost similar speed.