Skip to content

Commit

Permalink
Merge branch 'develop' of repo.ch.internal:oss/spindle into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nevali committed Aug 11, 2017
2 parents 12ec52d + 4cf9ec9 commit aa980a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions quilt/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ AWSS3BUCKET *spindle_bucket;
char *spindle_cachepath;
SQL *spindle_db;
int spindle_s3_verbose;
long spindle_s3_fetch_limit;

static int spindle_cache_init_(void);
static int spindle_cache_init_s3_(const char *bucket);
Expand Down Expand Up @@ -161,6 +162,10 @@ spindle_cache_init_s3_(const char *bucket)
aws_s3_set_secret(spindle_bucket, t);
free(t);
}

// As its in terms of kbs
spindle_s3_fetch_limit = 1024 * quilt_config_get_int("s3:fetch_limit", DEFAULT_SPINDLE_FETCH_LIMIT);

spindle_s3_verbose = quilt_config_get_bool("s3:verbose", 0);
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions quilt/p_spindle.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

# define SPINDLE_THRESHOLD 40

# define DEFAULT_SPINDLE_FETCH_LIMIT ( 2 * 1024 )

# define MIME_NQUADS "application/n-quads"

/* Namespaces */
Expand Down
9 changes: 9 additions & 0 deletions quilt/s3.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "p_spindle.h"

extern long spindle_s3_fetch_limit;

struct data_struct
{
char *buf;
Expand Down Expand Up @@ -132,6 +134,13 @@ spindle_s3_write_(char *ptr, size_t size, size_t nemb, void *userdata)
data = (struct data_struct *) userdata;

size *= nemb;

if(spindle_s3_fetch_limit && size > spindle_s3_fetch_limit)
{
quilt_logf(LOG_WARNING, QUILT_PLUGIN_NAME ": S3: failing write due to size exceeding fetch limit. input_size:%u > fetch_limit:%u \n", size, spindle_s3_fetch_limit);
return 0;
}

if(data->pos + size >= data->size)
{
p = (char *) realloc(data->buf, data->size + size + 1);
Expand Down

0 comments on commit aa980a5

Please sign in to comment.