Asterisk, Call next agent if present will refuse a call - queue

I have a queue with few agents and leastrecent as strategy and timeout is set up on 10(sec). When phone ring and agent push 'busy' button i will that asterisk ring to next free agent without waiting sets up timeout.
It is possible to set up?

Try this in queue configuration:
timeoutrestart=yes
ringinuse=no

Related

How socketcan get send failure status?

As we all know, in the CAN bus communication protocol, sender know whether the data was successfully sent. I send socketcan data as follows.
ret = write (socket, frame, sizeof (struct can_frame));
However, even if the CAN communication cable is disconnected, the return value of ret is still 16(=sizeof (struct can_frame)).I queried the information and found that the problem was due to the tx_queue of the network stack used by socketcan. When write is called multiple times, the buffer is full and the return value of ret is -1.
But this is not the behavior I expect, I hope that every frame of data sent will immediately get the status of success or failure.
By
echo 0> / sys / class / net / can0 / tx_queue_len
I want to cancel the tx_queue, but it does not work.
What I want to ask is, is there a way to cancel the tx_queue of socketcan, or to get the status of the each sending frame about controller through the API (such as libsocketcan).
Thanks.
You cannot use write() itself to discover whether a CAN frame was successfully put on the bus, because all it does is write the frame to the in-kernel socket buffer. The kernel then moves the frame to the transmit queue of the SocketCAN network interface, followed by the driver moving it to the transmit buffer of the CAN controller, which finally puts the frame on the bus. What you want is a direct write which bypasses all those buffers, but that's not possible with SocketCAN, even if you set the transmit queue length to 0.
However, there is another way to get confirmation. If you enable the CAN_RAW_RECV_OWN_MSGS socket option (see section 4.1.4 and 4.1.7 in the SocketCAN documentation), you will receive frames that were successfully sent. You'll need to use recvmsg() so you get the message flags. msg_flags will have the MSG_CONFIRM bit set for a frames that was successfully sent by the same socket on which it is received. You won't be informed of failures, but you can detect them by using a timeout for the confirmation.
It's not an ideal solution because it mixes the read and write logic in your application. One way to avoid this would be to use two sockets. One for writing and reading MSG_CONFIRM frames, the other for reading all other frames. You could then create a (blocking) write function that does a write() followed by multiple calls to recvmsg() with an appropriate timeout.
Finally, it is useful to enable error frames (through the CAN_RAW_ERR_FILTER socket option). If you send a frame on a socket with a disconnected cable, this will typically result in a bus off state, which will be reported in an error frame.

Starting and stopping a server

So let's say I have a Tk interface with 2 buttons. I want one of them to start a server and one of them to close the server.
The code for the start button:
syslog "Server is Opened"
config
socket -server accept 12345
vwait forever
What do I have to write in the stop button to stop this server? Or should starting and stopping the server happen in the same button, and how?
To shut down a server socket, you need to keep its handle around and close it when you no longer want it.
syslog "Server is Opened"
config
set number_of_connected_clients 0
set server [socket -server accept 12345]
vwait until_time_to_stop
close $server
# You probably want some extra time/code here to let clients disconnect gracefully
while {$number_of_connected_clients > 0} {
vwait number_of_connected_clients
}
exit
Then you can trigger a shutdown by doing this (in a callback):
set ::until_time_to_stop "now, please"
The actual value you set the variable to is pretty arbitrary. The tricky part is that you also usually want to let any connected clients finish their business. To make the code above work, just increment the global number_of_connected_clients when a client connects (in the accept procedure probably) and decrement it again when you close your side of the client connection. There's other ways to achieve the same effect (e.g., by keeping client handles in a global array and vwaiting on that at the end with [array size handles] as the test) but it's just a variation on a theme.

Asterisk - Wrap up time on Outbound Call

Is there a way to manually set up wrapuptime for 'OUTBOUND' queue in Asterisk?. What i want to achieve is when agents makes an outbound call (successful) after hangup he is paused for i.e. 10 seconds before either taking inbound call or making another outbound call.
You can use astdb, hangup handler, dialplan check.
Plan is like that:
1) Before call check ${DB(/CHECK/${CALLERID(num)})} value if it exist or if time in it less then 10 sec in past.
2) Setup hangup handler for this call.
3) In hangup, put current timestamp to DB(/CHECK/${CALLERID(num)}), so it can be checked in 1) for next call.

Process termination by his parent or other processes

Does an only father process can terminate (kill) his children? Or even another process without any relation to that specific process can kill it?
which processes can kill the specific process?
Any process that has process ID of another process with same user-id can terminate it by sending a SIGQUIT signal to that process using
kill(pid, SIGQUIT).
You need to include <sys/types.h>
and <signal.h> for using this system call.
It is stated on man page of kill:
For a process to have permission to send a signal it must either be privileged (under Linux: have the CAP_KILL capability), or the real or effective user ID of the sending process must equal the real or saved set-user-ID of the target process. In the case of SIGCONT it suffices when the sending and receiving processes belong to the same session.

socket program setup

I am writing my first socket program to connect to my host to server running on other PC.
I am referring following link but did not got what is the meaning of this line.
http://www.thegeekstuff.com/2011/12/c-socket-programming/
The call to the function ‘listen()’ with second argument as ’10′
specifies maximum number of client connections that server will queue
for this listening socket.
Means to say that it will listen 10 times to new connection request. what actually happen at listen :?:
We will enter while loop once some client connect onto the socket right And inside while loop does accept blocks if no client is requesting to connect to socket on second loop of while :?:
When we are inside while loop does listen() system call is still working or terminates :?:
Also when we will get out of while loop :?:
Please can someone on forum can help me to understand this.
What the listen call does is tell the system the size of the queue it should use for new connections. This queue is only used for connections you have not accepted yet, so it's not the number of total connections you will have.
Besides setting the size of the incoming-connections queue, it also sets a flag on the socket that says it's a passive listening socket.
The stuff that listen does is set on the socket, so as long as the socket is open the queue and the flag is valid.