aboutsummaryrefslogtreecommitdiffstats
path: root/o3000.c
diff options
context:
space:
mode:
authorsophia.papagiannaki <papagiannaki@stettbacher.ch>2020-07-28 15:12:47 +0200
committersophia.papagiannaki <papagiannaki@stettbacher.ch>2020-07-28 15:12:47 +0200
commit8ad61ce3a1ac60f62d792c26831a7413ab573d79 (patch)
tree82fd71ffdec7b3ba1525f013cbb564a81aea08ad /o3000.c
parentModified some debug/error messages. (diff)
downloado3000-driver-8ad61ce3a1ac60f62d792c26831a7413ab573d79.tar.gz
o3000-driver-8ad61ce3a1ac60f62d792c26831a7413ab573d79.zip
Working copy for testing on Windows.
Diffstat (limited to '')
-rw-r--r--o3000.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/o3000.c b/o3000.c
index 37c0ab7..12c5ff1 100644
--- a/o3000.c
+++ b/o3000.c
@@ -869,23 +869,25 @@ int __stdcall o3000_send_xml(int id, const char *msg, int msg_len) {
}
/**
- * Check whether all connections are closed.
+ * Get the number of open sessions.
*
- * @return 0 if all sessions are closed, error code otherwise defined at @ref o3000.h.
+ * @return number of open sessions
*/
-static int check_sessions(void) {
- int i;
+static int get_num_open_sessions(void) {
+ int i, num_sessions = 0;
for(i = 0; i < MAX_NUM_SESSION; i++) {
if(session_table[i] != NULL) {
- break;
+ num_sessions ++;
}
}
- if (i < MAX_NUM_SESSION) {
- printf("%s: Session %d is still open.\n", __func__, i);
- return O3000_ERROR_SESSION_STILL_OPEN;
- }
- return 0;
+ return num_sessions;
+
+// if (i < MAX_NUM_SESSION) {
+// printf("%s: Session %d is still open.\n", __func__, i);
+// return O3000_ERROR_SESSION_STILL_OPEN;
+// }
+// return 0;
}
/**
@@ -897,7 +899,7 @@ static int check_sessions(void) {
*/
int __stdcall o3000_firmware_update(unsigned char *data, int data_len) {
- int ret = 0;
+ int ret = 0, num_sessions;
// paranoia checks
if(data == NULL) {
@@ -912,7 +914,9 @@ int __stdcall o3000_firmware_update(unsigned char *data, int data_len) {
}
// checking whether all connections are closed
- if ((ret = check_sessions())) {
+ num_sessions = get_num_open_sessions();
+ if (num_sessions > 0) {
+ ret = O3000_ERROR_SESSION_STILL_OPEN;
printf("%s: Cannot proceed to firmware update: error code: %d.\n", __func__, ret);
return ret;
}