@@ -72,6 +72,7 @@ struct JDistributedObjectBackgroundData
7272 struct
7373 {
7474 JList * bytes_written ;
75+ guint64 total_bytes_written ;
7576 } write ;
7677 };
7778};
@@ -440,6 +441,7 @@ j_distributed_object_write_background_operation(gpointer data)
440441 guint64 * bytes_written = j_list_iterator_get (it );
441442
442443 nbytes = j_message_get_8 (reply );
444+ background_data -> write .total_bytes_written += nbytes ;
443445 j_helper_atomic_add (bytes_written , nbytes );
444446 }
445447 }
@@ -983,13 +985,17 @@ j_distributed_object_write_exec(JList* operations, JSemantics* semantics)
983985 gsize name_len = 0 ;
984986 gsize namespace_len = 0 ;
985987 guint32 server_count = 0 ;
988+ guint64 total_data_length = 0 ;
989+ JSemanticsSafety safety ;
986990
987991 /// \todo
988992 //JLock* lock = NULL;
989993
990994 g_return_val_if_fail (operations != NULL , FALSE);
991995 g_return_val_if_fail (semantics != NULL , FALSE);
992996
997+ safety = j_semantics_get (semantics , J_SEMANTICS_SAFETY );
998+
993999 {
9941000 JDistributedObjectOperation * operation = j_list_get_first (operations );
9951001 g_assert (operation != NULL );
@@ -1075,10 +1081,14 @@ j_distributed_object_write_exec(JList* operations, JSemantics* semantics)
10751081 new_data += new_length ;
10761082
10771083 // Fake bytes_written here instead of doing another loop further down
1078- if (j_semantics_get ( semantics , J_SEMANTICS_SAFETY ) == J_SEMANTICS_SAFETY_NONE )
1084+ if (safety == J_SEMANTICS_SAFETY_NONE )
10791085 {
10801086 j_helper_atomic_add (bytes_written , new_length );
10811087 }
1088+ else
1089+ {
1090+ total_data_length += new_length ;
1091+ }
10821092 }
10831093 }
10841094 else
@@ -1114,13 +1124,15 @@ j_distributed_object_write_exec(JList* operations, JSemantics* semantics)
11141124 data -> operations = NULL ;
11151125 data -> semantics = semantics ;
11161126 data -> write .bytes_written = bw_lists [i ];
1127+ data -> write .total_bytes_written = 0 ;
11171128 data -> ret = TRUE;
11181129
11191130 background_data [i ] = data ;
11201131 }
11211132
11221133 j_helper_execute_parallel (j_distributed_object_write_background_operation , background_data , server_count );
11231134
1135+ guint64 total_written = 0 ;
11241136 for (guint i = 0 ; i < server_count ; i ++ )
11251137 {
11261138 JDistributedObjectBackgroundData * data ;
@@ -1132,9 +1144,17 @@ j_distributed_object_write_exec(JList* operations, JSemantics* semantics)
11321144
11331145 data = background_data [i ];
11341146 ret = data -> ret && ret ;
1147+ total_written += data -> write .total_bytes_written ;
11351148
11361149 g_slice_free (JDistributedObjectBackgroundData , data );
11371150 }
1151+ if (safety == J_SEMANTICS_SAFETY_STORAGE || safety == J_SEMANTICS_SAFETY_NETWORK )
1152+ {
1153+ if (total_written != total_data_length )
1154+ {
1155+ ret = FALSE;
1156+ }
1157+ }
11381158 }
11391159 else
11401160 {
0 commit comments