Commit 97de236655ad9f6cc27203322e0da89d0d1f261c
1 parent
f553333f
Exists in
master
and in
3 other branches
Looking for performance issues in lib3270_wait_for_ready.
Showing
2 changed files
with
20 additions
and
3 deletions
Show diff stats
src/core/wait.c
| ... | ... | @@ -50,6 +50,9 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) |
| 50 | 50 | { |
| 51 | 51 | FAIL_IF_NOT_ONLINE(hSession); |
| 52 | 52 | |
| 53 | + debug("%s",__FUNCTION__); | |
| 54 | + debug("Session lock state is %d",lib3270_get_lock_status(hSession)); | |
| 55 | + | |
| 53 | 56 | int rc = 0; |
| 54 | 57 | int timeout = 0; |
| 55 | 58 | void * timer = AddTimer(seconds * 1000, hSession, timer_expired, &timeout); |
| ... | ... | @@ -58,11 +61,14 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) |
| 58 | 61 | { |
| 59 | 62 | if(timeout) { |
| 60 | 63 | // Timeout! The timer was destroyed. |
| 64 | + debug("%s exits with ETIMEDOUT",__FUNCTION__); | |
| 61 | 65 | return errno = ETIMEDOUT; |
| 62 | 66 | } |
| 63 | 67 | |
| 64 | - if(!lib3270_get_lock_status(hSession)) | |
| 68 | + if(lib3270_get_lock_status(hSession) == LIB3270_MESSAGE_NONE) | |
| 65 | 69 | { |
| 70 | + // Is unlocked, break. | |
| 71 | + | |
| 66 | 72 | break; |
| 67 | 73 | } |
| 68 | 74 | |
| ... | ... | @@ -82,6 +88,7 @@ LIB3270_EXPORT int lib3270_wait_for_ready(H3270 *hSession, int seconds) |
| 82 | 88 | } |
| 83 | 89 | RemoveTimer(hSession,timer); |
| 84 | 90 | |
| 91 | + debug("%s exits with rc=%d",__FUNCTION__,rc); | |
| 85 | 92 | return rc; |
| 86 | 93 | |
| 87 | 94 | } | ... | ... |
src/testprogram/testprogram.c
| ... | ... | @@ -161,9 +161,20 @@ int main(int argc, char *argv[]) |
| 161 | 161 | { |
| 162 | 162 | printf("\n\nWaiting starts %u\n",(unsigned int) time(NULL)); |
| 163 | 163 | lib3270_wait_for_ready(h,10); |
| 164 | + | |
| 165 | + { | |
| 166 | + // Performance checks | |
| 167 | + size_t f; | |
| 168 | + time_t start = time(0); | |
| 169 | + for(f=0;f < 1000; f++) { | |
| 170 | + lib3270_wait_for_ready(h,10); | |
| 171 | + } | |
| 172 | + printf("Time for 1000 iterations of wait_for_ready was %d\n",(int) (time(0) - start)); | |
| 173 | + | |
| 174 | + } | |
| 175 | + | |
| 164 | 176 | printf("Waiting ends %u\n\n",(unsigned int) time(NULL)); |
| 165 | 177 | |
| 166 | - /* | |
| 167 | 178 | lib3270_enter(h); |
| 168 | 179 | lib3270_wait(h,5); |
| 169 | 180 | |
| ... | ... | @@ -185,7 +196,6 @@ int main(int argc, char *argv[]) |
| 185 | 196 | if(text) |
| 186 | 197 | printf("Screen:\n[%s]\n",text); |
| 187 | 198 | } |
| 188 | - */ | |
| 189 | 199 | |
| 190 | 200 | lib3270_disconnect(h); |
| 191 | 201 | ... | ... |