Changeset 24939
- Timestamp:
- Jul 29, 2009, 11:30:24 AM (17 years ago)
- Location:
- trunk/Nebulous/nebclient
- Files:
-
- 3 edited
-
src/nebclient.c (modified) (6 diffs)
-
src/nebclient.h (modified) (1 diff)
-
tests/tests.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/nebclient/src/nebclient.c
r24931 r24939 833 833 } 834 834 835 void nebObjectStatFree(nebObjectStat *stat) 836 { 837 if (!stat) { 838 return; 839 } 840 841 xfree(stat->so_id); 842 xfree(stat->ext_id); 843 xfree(stat->read_lock); 844 xfree(stat->write_lock); 845 xfree(stat->epoch); 846 xfree(stat->mtime); 847 xfree(stat); 848 } 849 835 850 836 851 int nebChmod(nebServer *server, const char *key, mode_t mode) 837 852 { 838 int response;839 840 853 REQUIRE_SERVER; 841 854 … … 849 862 // manual seems to 'suggest' that this is temporary data that gets cleaed 850 863 // up on the next soap function call 864 int response; 851 865 if (soap_call_ns1__chmod_USCOREobject(server->soap, server->endpoint, 852 866 NULL, (char *)key, mode, &response) != SOAP_OK) { … … 861 875 int nebPrune(nebServer *server, const char *key) 862 876 { 863 int response;864 865 877 REQUIRE_SERVER; 866 878 … … 874 886 // manual seems to 'suggest' that this is temporary data that gets cleaed 875 887 // up on the next soap function call 888 int response; 876 889 if (soap_call_ns1__prune_USCOREobject(server->soap, server->endpoint, 877 890 NULL, (char *)key, &response) != SOAP_OK) { … … 893 906 } 894 907 908 // first - strip off any inaccesible instances 895 909 if (nebPrune(server, key) < 0 ) { 896 } 897 910 // use the prune() method to also determine if $key is valid 911 return -1; 912 } 913 914 // check to see if there is an instance on $vol_name that should be the 915 // sole survivor 898 916 nebObjectInstances *locations = NULL; 899 917 if (volume) { … … 901 919 } 902 920 921 long removed = 0; 903 922 if (locations && locations->n) { 904 923 nebObjectInstances *instances = nebFindInstances(server, key, NULL); 905 924 for (long i = 0; i < instances->n; i++) { 906 if (strcmp(locations->URI[0], instances->URI[i]) ) {907 nebDeleteInstance(server, key, instances->URI[i]);925 if (strcmp(locations->URI[0], instances->URI[i]) == 0) { 926 continue; 908 927 } 928 if (!nebDeleteInstance(server, key, instances->URI[i])) { 929 nebObjectInstancesFree(instances); 930 nebObjectInstancesFree(locations); 931 return -1; 932 } 933 removed++; 909 934 } 910 935 nebObjectInstancesFree(instances); 911 } 912 nebObjectInstancesFree(locations); 913 914 915 return 0; 936 nebObjectInstancesFree(locations); 937 } else { 938 // nuke whatever 939 nebObjectStat *stat = nebStat(server, key); 940 if (!stat) { 941 return -1; 942 } 943 // start at one so cull() is called one less time then the # of 944 // instances 945 for (long i = 1; i < stat->available; i++) { 946 if (!nebCull(server, key)) { 947 nebObjectStatFree(stat); 948 return -1; 949 } 950 removed++; 951 } 952 nebObjectStatFree(stat); 953 } 954 955 return removed; 916 956 } 917 957 -
trunk/Nebulous/nebclient/src/nebclient.h
r24931 r24939 299 299 ); 300 300 301 302 /** Deallocates a stat object 303 */ 304 void nebObjectStatFree( 305 nebObjectStat *stat ///< nebObjectStat object 306 ); 307 301 308 /** Change permissions of a storage objects 302 309 * -
trunk/Nebulous/nebclient/tests/tests.c
r24923 r24939 20 20 char *key = "foobarbaz"; 21 21 22 plan_tests(3 0);22 plan_tests(31); 23 23 24 24 if (getenv("NEB_SERVER")) { … … 141 141 neb_ok(server, nebPrune(server, "movedfile") == 0, "prune object"); 142 142 143 nebReplicate(server, key, NULL, NULL); 144 neb_ok(server, nebThereCanBeOnlyOne(server, "movedfile", NULL) == 0, "reduce instances to only 1"); 145 143 146 if (!nebDelete(server, "movedfile")) { 144 147 diag( "cleanup failed %s\n", nebErr(server));
Note:
See TracChangeset
for help on using the changeset viewer.
