~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to camel/camel-block-file.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
 
83
83
        retval = fstat (bs->fd, &st);
84
84
 
85
 
        d(printf("Validate root: '%s'\n", bs->path));
86
 
        d(printf("version: %.8s (%.8s)\n", bs->root->version, bs->version));
87
 
        d(printf("block size: %d (%d)%s\n", br->block_size, bs->block_size,
 
85
        d (printf ("Validate root: '%s'\n", bs->path));
 
86
        d (printf ("version: %.8s (%.8s)\n", bs->root->version, bs->version));
 
87
        d (printf (
 
88
                "block size: %d (%d)%s\n",
 
89
                br->block_size, bs->block_size,
88
90
                br->block_size != bs->block_size ? " BAD":" OK"));
89
 
        d(printf("free: %ld (%d add size < %ld)%s\n", (glong)br->free, br->free / bs->block_size * bs->block_size, (glong)st.st_size,
90
 
                (br->free > st.st_size) || (br->free % bs->block_size) != 0 ? " BAD":" OK"));
91
 
        d(printf("last: %ld (%d and size: %ld)%s\n", (glong)br->last, br->last / bs->block_size * bs->block_size, (glong)st.st_size,
92
 
                (br->last != st.st_size) || ((br->last % bs->block_size) != 0) ? " BAD": " OK"));
93
 
        d(printf("flags: %s\n", (br->flags & CAMEL_BLOCK_FILE_SYNC)?"SYNC":"unSYNC"));
 
91
        d (printf (
 
92
                "free: %ld (%d add size < %ld)%s\n",
 
93
                (glong) br->free,
 
94
                br->free / bs->block_size * bs->block_size,
 
95
                (glong) st.st_size,
 
96
                (br->free > st.st_size) ||
 
97
                (br->free % bs->block_size) != 0 ? " BAD":" OK"));
 
98
        d (printf (
 
99
                "last: %ld (%d and size: %ld)%s\n",
 
100
                (glong) br->last,
 
101
                br->last / bs->block_size * bs->block_size,
 
102
                (glong) st.st_size,
 
103
                (br->last != st.st_size) ||
 
104
                ((br->last % bs->block_size) != 0) ? " BAD": " OK"));
 
105
        d (printf (
 
106
                "flags: %s\n",
 
107
                (br->flags & CAMEL_BLOCK_FILE_SYNC) ? "SYNC" : "unSYNC"));
94
108
 
95
109
        if (br->last == 0
96
110
            || memcmp (bs->root->version, bs->version, 8) != 0
101
115
            || st.st_size != br->last
102
116
            || br->free > st.st_size
103
117
            || (br->flags & CAMEL_BLOCK_FILE_SYNC) == 0) {
104
 
#if 0
105
 
                if (retval != -1 && st.st_size > 0) {
106
 
                        g_warning("Invalid root: '%s'", bs->path);
107
 
                        g_warning("version: %.8s (%.8s)", bs->root->version, bs->version);
108
 
                        g_warning("block size: %d (%d)%s", br->block_size, bs->block_size,
109
 
                                  br->block_size != bs->block_size ? " BAD":" OK");
110
 
                        g_warning("free: %ld (%d add size < %ld)%s", (glong)br->free, br->free / bs->block_size * bs->block_size, (glong)st.st_size,
111
 
                                  (br->free > st.st_size) || (br->free % bs->block_size) != 0 ? " BAD":" OK");
112
 
                        g_warning("last: %ld (%d and size: %ld)%s", (glong)br->last, br->last / bs->block_size * bs->block_size, (glong)st.st_size,
113
 
                                  (br->last != st.st_size) || ((br->last % bs->block_size) != 0) ? " BAD": " OK");
114
 
                        g_warning("flags: %s", (br->flags & CAMEL_BLOCK_FILE_SYNC)?"SYNC":"unSYNC");
115
 
                }
116
 
#endif
117
118
                return -1;
118
119
        }
119
120
 
160
161
 
161
162
        while ((bl = g_queue_pop_head (&bs->block_cache)) != NULL) {
162
163
                if (bl->refcount != 0)
163
 
                        g_warning("Block '%u' still referenced", bl->id);
 
164
                        g_warning ("Block '%u' still referenced", bl->id);
164
165
                g_free (bl);
165
166
        }
166
167
 
250
251
                errno = ENOENT;
251
252
                return -1;
252
253
        } else {
253
 
                d(printf("Turning block file online: %s\n", bs->path));
 
254
                d (printf ("Turning block file online: %s\n", bs->path));
254
255
        }
255
256
 
256
257
        if ((bs->fd = g_open (bs->path, bs->flags | O_BINARY, 0600)) == -1) {
283
284
                        if (CAMEL_BLOCK_FILE_TRYLOCK (bf, root_lock)) {
284
285
                                if (CAMEL_BLOCK_FILE_TRYLOCK (bf, cache_lock)) {
285
286
                                        if (CAMEL_BLOCK_FILE_TRYLOCK (bf, io_lock)) {
286
 
                                                d(printf("[%d] Turning block file offline: %s\n", block_file_count-1, bf->path));
 
287
                                                d (printf ("[%d] Turning block file offline: %s\n", block_file_count - 1, bf->path));
287
288
                                                sync_nolock (bf);
288
289
                                                close (bf->fd);
289
290
                                                bf->fd = -1;
370
371
 
371
372
        /* Do we need to init the root block? */
372
373
        if (class->validate_root (bs) == -1) {
373
 
                d(printf("Initialise root block: %.8s\n", version));
 
374
                d (printf ("Initialise root block: %.8s\n", version));
374
375
 
375
376
                class->init_root (bs);
376
377
                camel_block_file_touch_block (bs, bs->root_block);
457
458
 * Allocate a new block, return a pointer to it.  Old blocks
458
459
 * may be flushed to disk during this call.
459
460
 *
460
 
 * Returns: The block, or NULL if an error occured.
 
461
 * Returns: The block, or NULL if an error occurred.
461
462
 **/
462
463
CamelBlock *
463
464
camel_block_file_new_block (CamelBlockFile *bs)
530
531
 * Retreive a block @id.
531
532
 *
532
533
 * Returns: The block, or NULL if blockid is invalid or a file error
533
 
 * occured.
 
534
 * occurred.
534
535
 **/
535
536
CamelBlock *
536
537
camel_block_file_get_block (CamelBlockFile *bs,
553
554
 
554
555
        bl = g_hash_table_lookup (bs->blocks, GUINT_TO_POINTER (id));
555
556
 
556
 
        d(printf("Get  block %08x: %s\n", id, bl?"cached":"must read"));
 
557
        d (printf ("Get  block %08x: %s\n", id, bl?"cached":"must read"));
557
558
 
558
559
        if (bl == NULL) {
559
560
                GQueue trash = G_QUEUE_INIT;
612
613
 
613
614
        CAMEL_BLOCK_FILE_UNLOCK (bs, cache_lock);
614
615
 
615
 
        d(printf("Got  block %08x\n", id));
 
616
        d (printf ("Got  block %08x\n", id));
616
617
 
617
618
        return bl;
618
619
}
687
688
        bl->flags |= CAMEL_BLOCK_DIRTY;
688
689
 
689
690
        if ((bs->root->flags & CAMEL_BLOCK_FILE_SYNC) && bl != bs->root_block) {
690
 
                d(printf("turning off sync flag\n"));
 
691
                d (printf ("turning off sync flag\n"));
691
692
                bs->root->flags &= ~CAMEL_BLOCK_FILE_SYNC;
692
693
                bs->root_block->flags |= CAMEL_BLOCK_DIRTY;
693
694
                camel_block_file_sync_block (bs, bs->root_block);
729
730
sync_block_nolock (CamelBlockFile *bs,
730
731
                   CamelBlock *bl)
731
732
{
732
 
        d(printf("Sync block %08x: %s\n", bl->id, (bl->flags & CAMEL_BLOCK_DIRTY)?"dirty":"clean"));
 
733
        d (printf ("Sync block %08x: %s\n", bl->id, (bl->flags & CAMEL_BLOCK_DIRTY)?"dirty":"clean"));
733
734
 
734
735
        if (bl->flags & CAMEL_BLOCK_DIRTY) {
735
736
                if (lseek (bs->fd, bl->id, SEEK_SET) == -1
765
766
            && (bs->root->flags & CAMEL_BLOCK_FILE_SYNC) != 0)
766
767
                return 0;
767
768
 
768
 
        d(printf("turning on sync flag\n"));
 
769
        d (printf ("turning on sync flag\n"));
769
770
 
770
771
        bs->root->flags |= CAMEL_BLOCK_FILE_SYNC;
771
772
        bs->root_block->flags |= CAMEL_BLOCK_DIRTY;
938
939
                errno = ENOENT;
939
940
                return -1;
940
941
        } else {
941
 
                d(printf("Turning key file online: '%s'\n", bs->path));
 
942
                d (printf ("Turning key file online: '%s'\n", bs->path));
942
943
        }
943
944
 
944
945
        if ((bs->flags & O_ACCMODE) == O_RDONLY)
976
977
                        /* Need to trylock, as any of these lock levels might be trying
977
978
                         * to lock the key_file_lock, so we need to check and abort if so */
978
979
                        if (CAMEL_BLOCK_FILE_TRYLOCK (bf, lock)) {
979
 
                                d(printf("Turning key file offline: %s\n", bf->path));
 
980
                                d (printf ("Turning key file offline: %s\n", bf->path));
980
981
                                fclose (bf->fp);
981
982
                                bf->fp = NULL;
982
983
                                key_file_count--;
1029
1030
        goffset last;
1030
1031
        gint err;
1031
1032
 
1032
 
        d(printf("New key file '%s'\n", path));
 
1033
        d (printf ("New key file '%s'\n", path));
1033
1034
 
1034
1035
        kf = g_object_new (CAMEL_TYPE_KEY_FILE, NULL);
1035
1036
        kf->path = g_strdup (path);
1149
1150
        g_return_val_if_fail (parent != NULL, -1);
1150
1151
        g_return_val_if_fail (records != NULL, -1);
1151
1152
 
1152
 
        d(printf("write key %08x len = %d\n", *parent, len));
 
1153
        d (printf ("write key %08x len = %d\n", *parent, len));
1153
1154
 
1154
1155
        if (len == 0) {
1155
 
                d(printf(" new parent = %08x\n", *parent));
 
1156
                d (printf (" new parent = %08x\n", *parent));
1156
1157
                return 0;
1157
1158
        }
1158
1159
 
1180
1181
        /* UNLOCK */
1181
1182
        key_file_unuse (kf);
1182
1183
 
1183
 
        d(printf(" new parent = %08x\n", *parent));
 
1184
        d (printf (" new parent = %08x\n", *parent));
1184
1185
 
1185
1186
        return ret;
1186
1187
}