Changeset 71 for trunk/samba/source/libsmb/libsmbclient.c
- Timestamp:
- Sep 13, 2007, 8:44:04 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/samba/source/libsmb/libsmbclient.c
r62 r71 504 504 struct sockaddr addr; 505 505 506 /* 507 * Although the use of port 139 is not a guarantee that we're using 508 * netbios, we assume so. We don't want to send a keepalive packet if 509 * not netbios because it's not valid, and Vista, at least, 510 * disconnects the client on such a request. 511 */ 512 if (server->cli->port == 139) { 513 /* Assuming netbios. Send a keepalive packet */ 514 if ( send_keepalive(server->cli->fd) == False ) { 515 return 1; 516 } 517 } else { 518 /* 519 * Assuming not netbios. Try a different method to detect if 520 * the connection is still alive. 521 */ 522 size = sizeof(addr); 523 if (getpeername(server->cli->fd, &addr, &size) == -1) { 524 return 1; 525 } 526 } 527 528 /* connection is ok */ 529 return 0; 506 size = sizeof(addr); 507 return (getpeername(server->cli->fd, &addr, &size) == -1); 530 508 } 531 509 … … 565 543 DEBUG(3, ("smbc_remove_usused_server: %p removed.\n", srv)); 566 544 567 context->callbacks.remove_cached_srv_fn(context, srv);545 (context->callbacks.remove_cached_srv_fn)(context, srv); 568 546 569 547 SAFE_FREE(srv); … … 585 563 check_server_cache: 586 564 587 srv = context->callbacks.get_cached_srv_fn(context, server, share,588 565 srv = (context->callbacks.get_cached_srv_fn)(context, server, share, 566 workgroup, username); 589 567 590 568 if (!auth_called && !srv && (!username[0] || !password[0])) { 591 569 if (context->internal->_auth_fn_with_context != NULL) { 592 context->internal->_auth_fn_with_context(570 (context->internal->_auth_fn_with_context)( 593 571 context, 594 572 server, share, … … 597 575 password, sizeof(fstring)); 598 576 } else { 599 context->callbacks.auth_fn(577 (context->callbacks.auth_fn)( 600 578 server, share, 601 579 workgroup, sizeof(fstring), … … 615 593 616 594 if (srv) { 617 if ( context->callbacks.check_server_fn(context, srv)) {595 if ((context->callbacks.check_server_fn)(context, srv)) { 618 596 /* 619 597 * This server is no good anymore … … 621 599 * servers in the cache 622 600 */ 623 if ( context->callbacks.remove_unused_server_fn(context,624 srv)) {601 if ((context->callbacks.remove_unused_server_fn)(context, 602 srv)) { 625 603 /* 626 604 * We could not remove the server completely, … … 629 607 * file/dir is closed. 630 608 */ 631 context->callbacks.remove_cached_srv_fn(context,632 srv);609 (context->callbacks.remove_cached_srv_fn)(context, 610 srv); 633 611 } 634 612 … … 707 685 /* Ensure we have accurate auth info */ 708 686 if (context->internal->_auth_fn_with_context != NULL) { 709 context->internal->_auth_fn_with_context(687 (context->internal->_auth_fn_with_context)( 710 688 context, 711 689 server, share, … … 714 692 password, sizeof(fstring)); 715 693 } else { 716 context->callbacks.auth_fn(694 (context->callbacks.auth_fn)( 717 695 server, share, 718 696 workgroup, sizeof(fstring), … … 727 705 cli_shutdown(srv->cli); 728 706 srv->cli = NULL; 729 context->callbacks.remove_cached_srv_fn(context,730 srv);707 (context->callbacks.remove_cached_srv_fn)(context, 708 srv); 731 709 srv = NULL; 732 710 } … … 905 883 /* Let the cache function set errno if it wants to */ 906 884 errno = 0; 907 if (context->callbacks.add_cached_srv_fn(context, srv, server, share, workgroup, username)) { 885 if ((context->callbacks.add_cached_srv_fn)(context, srv, 886 server, share, 887 workgroup, username)) { 908 888 int saved_errno = errno; 909 889 DEBUG(3, (" Failed to add server to cache\n")); … … 964 944 /* ... then retrieve it now. */ 965 945 if (context->internal->_auth_fn_with_context != NULL) { 966 context->internal->_auth_fn_with_context(946 (context->internal->_auth_fn_with_context)( 967 947 context, 968 948 server, share, … … 971 951 password, sizeof(fstring)); 972 952 } else { 973 context->callbacks.auth_fn(953 (context->callbacks.auth_fn)( 974 954 server, share, 975 955 workgroup, sizeof(fstring), … … 1043 1023 1044 1024 errno = 0; /* let cache function set errno if it likes */ 1045 if ( context->callbacks.add_cached_srv_fn(context, ipc_srv,1046 server,1047 "*IPC$",1048 workgroup,1049 username)) {1025 if ((context->callbacks.add_cached_srv_fn)(context, ipc_srv, 1026 server, 1027 "*IPC$", 1028 workgroup, 1029 username)) { 1050 1030 DEBUG(3, (" Failed to add server to cache\n")); 1051 1031 if (errno == 0) { … … 1210 1190 1211 1191 eno = smbc_errno(context, srv->cli); 1212 file = context->opendir(context, fname);1192 file = (context->opendir)(context, fname); 1213 1193 if (!file) errno = eno; 1214 1194 return file; … … 1449 1429 if (!file->file) { 1450 1430 1451 return context->closedir(context, file);1431 return (context->closedir)(context, file); 1452 1432 1453 1433 } … … 1486 1466 SAFE_FREE(file->fname); 1487 1467 SAFE_FREE(file); 1488 context->callbacks.remove_unused_server_fn(context, srv);1468 (context->callbacks.remove_unused_server_fn)(context, srv); 1489 1469 1490 1470 return -1; … … 2199 2179 if (!file->file) { 2200 2180 2201 return context->fstatdir(context, file, st);2181 return (context->fstatdir)(context, file, st); 2202 2182 2203 2183 } … … 2968 2948 cb = &context->callbacks; 2969 2949 if (cli_is_error(targetcli) && 2970 cb->check_server_fn(context, srv)) { 2971 2972 /* ... then remove it. */ 2973 if (cb->remove_unused_server_fn(context, 2974 srv)) { 2975 /* 2976 * We could not remove the server 2977 * completely, remove it from the 2978 * cache so we will not get it 2979 * again. It will be removed when the 2980 * last file/dir is closed. 2981 */ 2982 cb->remove_cached_srv_fn(context, srv); 2983 } 2950 (cb->check_server_fn)(context, srv)) { 2951 2952 /* ... then remove it. */ 2953 if ((cb->remove_unused_server_fn)(context, 2954 srv)) { 2955 /* 2956 * We could not remove the 2957 * server completely, remove 2958 * it from the cache so we 2959 * will not get it again. It 2960 * will be removed when the 2961 * last file/dir is closed. 2962 */ 2963 (cb->remove_cached_srv_fn)(context, 2964 srv); 2965 } 2984 2966 } 2985 2967 … … 6003 5985 /* What if the path is empty, or the file exists? */ 6004 5986 6005 return context->open(context, fname, O_WRONLY, 666);5987 return (context->open)(context, fname, O_WRONLY, 666); 6006 5988 6007 5989 } … … 6044 6026 /* Try to open the file for reading ... */ 6045 6027 6046 if ((long)(fid1 = c_file->open(c_file, fname, O_RDONLY, 0666)) < 0) {6028 if ((long)(fid1 = (c_file->open)(c_file, fname, O_RDONLY, 0666)) < 0) { 6047 6029 6048 6030 DEBUG(3, ("Error, fname=%s, errno=%i\n", fname, errno)); … … 6053 6035 /* Now, try to open the printer file for writing */ 6054 6036 6055 if ((long)(fid2 = c_print->open_print_job(c_print, printq)) < 0) {6037 if ((long)(fid2 = (c_print->open_print_job)(c_print, printq)) < 0) { 6056 6038 6057 6039 saverr = errno; /* Save errno */ 6058 c_file->close_fn(c_file, fid1);6040 (c_file->close_fn)(c_file, fid1); 6059 6041 errno = saverr; 6060 6042 return -1; … … 6062 6044 } 6063 6045 6064 while ((bytes = c_file->read(c_file, fid1, buf, sizeof(buf))) > 0) {6046 while ((bytes = (c_file->read)(c_file, fid1, buf, sizeof(buf))) > 0) { 6065 6047 6066 6048 tot_bytes += bytes; 6067 6049 6068 if (( c_print->write(c_print, fid2, buf, bytes)) < 0) {6050 if (((c_print->write)(c_print, fid2, buf, bytes)) < 0) { 6069 6051 6070 6052 saverr = errno; 6071 c_file->close_fn(c_file, fid1);6072 c_print->close_fn(c_print, fid2);6053 (c_file->close_fn)(c_file, fid1); 6054 (c_print->close_fn)(c_print, fid2); 6073 6055 errno = saverr; 6074 6056 … … 6079 6061 saverr = errno; 6080 6062 6081 c_file->close_fn(c_file, fid1); /* We have to close these anyway */6082 c_print->close_fn(c_print, fid2);6063 (c_file->close_fn)(c_file, fid1); /* We have to close these anyway */ 6064 (c_print->close_fn)(c_print, fid2); 6083 6065 6084 6066 if (bytes < 0) { … … 6330 6312 f = context->internal->_files; 6331 6313 while (f) { 6332 context->close_fn(context, f);6314 (context->close_fn)(context, f); 6333 6315 f = f->next; 6334 6316 } … … 6346 6328 s, s->cli->fd)); 6347 6329 cli_shutdown(s->cli); 6348 context->callbacks.remove_cached_srv_fn(context,6349 s);6330 (context->callbacks.remove_cached_srv_fn)(context, 6331 s); 6350 6332 next = s->next; 6351 6333 DLIST_REMOVE(context->internal->_servers, s); … … 6358 6340 else { 6359 6341 /* This is the polite way */ 6360 if ( context->callbacks.purge_cached_fn(context)) {6342 if ((context->callbacks.purge_cached_fn)(context)) { 6361 6343 DEBUG(1, ("Could not purge all servers, " 6362 6344 "free_context failed.\n"));
Note:
See TracChangeset
for help on using the changeset viewer.