Magellan Linux

Diff of /trunk/usbip/usbippolld-sql

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 208 by niro, Tue May 15 14:39:55 2007 UTC revision 209 by niro, Tue May 22 10:16:59 2007 UTC
# Line 3  Line 3 
3  source /etc/conf.d/usbippolld  source /etc/conf.d/usbippolld
4  source /usr/lib/alxconfig-ng/functions/mysqlfunctions  source /usr/lib/alxconfig-ng/functions/mysqlfunctions
5    
6    # reset connection status for all clients on daemon startup
7    mysqldo "update clients set connected='0'"
8    
9  while true  while true
10  do  do
11   ALLCLIENTS=$(mysqldo "select ip from clients")   ALLCLIENTS=$(mysqldo "select ip from clients")
# Line 16  do Line 19  do
19    
20   echo "-- polling client #${client} on dev ${BUSID}"   echo "-- polling client #${client} on dev ${BUSID}"
21   usbip -a ${client} ${BUSID}   usbip -a ${client} ${BUSID}
22    
23     # disconnect non reachable ports
24     if [[ -n $(out=$(mktemp);usbip -a ${client} ${BUSID} &> ${out}; grep '\[Connection refused\]' ${out}) ]] ||
25     [[ -n $(out=$(mktemp);usbip -a ${client} ${BUSID} &> ${out}; grep '\[No route to host\]' ${out}) ]]
26     then
27     echo "-- client #${client} *non* reachable on dev ${BUSID}; reset connection state"
28     mysqldo "update clients set connected='0', busid='' where ip='${client}'"
29     fi
30   else   else
31   echo "-- client #${client} not found, removing from list"   echo "-- client #${client} not found, removing from list"
32    
# Line 25  do Line 36  do
36    
37   mysqldo "update clients set connected='0', busid='' where ip='${client}'"   mysqldo "update clients set connected='0', busid='' where ip='${client}'"
38   fi   fi
39     # give the device the chance to (dis)connect
40     sleep 3
41   done   done
42    
43   sleep ${USBIP_WAIT_TIMEOUT}   sleep ${USBIP_WAIT_TIMEOUT}
44    
45    ## #TODO: fix driver b0rkage
46    # mage-lager ~ # usbip -d 05
47    # 8 ports available
48    #
49    # port 5 detached
50    # mage-lager ~ # usbip -p
51    # 8 ports available
52    #
53    # usbip err: vhci_driver.c:  60 (imported_device_init) sysfs_open_device 007  [No such file or directory]
54    # usbip err: vhci_driver.c: 140 (parse_status) init new device  [No such file or directory]
55    
56    
57     # disconnect all stale ports
58     staleports=$(out=$(mktemp);usbip -p &> ${out};grep '\<Port Initializing\>' ${out} | grep Port | cut -d' ' -f2 | sed "s|:||")
59     if [[ -n ${staleports} ]]
60     then
61     # wait some seconds, or driver may break !!
62     sleep ${USBIP_WAIT_TIMEOUT}
63     for port in ${staleports}
64     do
65     echo "-- disconnecting stale port #${port}"
66     usbip -d ${port}
67     # give the device the chance to disconnect
68     sleep 3
69     done
70     fi
71  done  done

Legend:
Removed from v.208  
changed lines
  Added in v.209